Excpected working:
-
Fully editing the graph - moving the vertices, drawing edges, everything
-
editing the graph in crossing-free mode - it should be impossible to make a crossing.
-
entering matchings mode if the graph is a perfect matching
- click on an edge, all edges with which a flip could be performed are now red, and the clicked edge is green
- click on one of the red edges, all other edges go back to black, and green lines are drawn for where the new lines would be drawn
- click on one of the green lines, the flip is perfromed
- the flip can be undone and re-done via history (ctrl+z or button)
- in the matcings mode, only flips can be undone/redone
-
entering reconfiguration mode if the graph is a geometric triangulation, cfst or cfsp
- click on an edge
- if no valid flip with it can be performed, a notification should appear informing the user of this
- otherwise, if it's a flippable edge, the flip should get indicated (or insta-flipped)
- click on a vertex
- see available vertexes that can be used for a new edge that would be valid flips highlighed as yellow
- click on one, the one of the green edges should be clicked to confirm (or insta-flipped)
- click on an edge
-
highlighting of colinear points
- it's a toggle, so it needs to be turned off again in the settings. It obstructs visibility for flipping
-
settings
- adjusting the hover/click proximity, colors, and by what factor the coordinates get multiplied
- adjusting the size of the vertices and edges in pixels (slider)
-
coordinate multiplaction
- it's at the bottom of the top part of the toolbar (icon is like small markers pointing diagonally)
-
re-zoom graph so that it's fully within the canvas
-
insta-flip toggle for perfect matchings and triangulations
- insta-flip toggle is at the very bottom of the settings view
-
keyboard shortcuts: P for paths, T for trees, G for geometric triangulations, and M for matchings. R tries all of the reconfiguration types in that order, and enters the first one that fits the current graph. E for edit mode
Expected not working:
- almost-perfect matchings
- show all possible flips button/toggle
- insta-flip toggle for almost-perfect matching
Note: Spiral graph with only 3 possible flips for matchings (with 3 'levels') can be found in data/matchings_only_3_flips_spiral_graph.txt
1.1 Purpose: This is Grapher, an interactive web-app for investigating graph reconfigurations! The primary motivation for this tool is to help us explore graph reconfigurations for a few main types of geometric graphs.
- Configurations are plane drawings of straight line graphs with labeled vertices
- A reconfiguration step, or a flip, is an exchange of (a bounded number of) edges
- Perfect Pairings / Matchings
- Almost-Perfect Pairings / Matchings
- Crossing-Free Spanning Trees
- Crossing-Free Spanning Paths
- Geometric Triangulations
1.3 Target Audience: Researchers, students, and anyone interested in exploring the structural properties and transformations of these specific graph classes.
An instance of the tool is hosted on GitHub pages.
The source code can also be found on Github. After cloning the repository, using the tool is as simple as opening the index.html file in the 'root' directory. Alternatively, the Live Server extension for VSCode can be used to speed up development (by default, it makes the tool accessible through localhost).
- A mouse or touchpad
- A modern web browser
The tool interface is divided into several key areas:
- 3.1. Graph Area (Canvas):
- The central panel where the graph is visually displayed.
- All direct graph manipulations (adding/moving nodes, adding/removing edges) happen here.
- Uses a grid background for reference.
- 3.2. Canvas toolbars :
- Contain buttons to switch between interaction modes or perform global actions.
- Main interactables:
[Graph]- Allows the user to switch between 'usage modes' - These include reconfigurations of each specific graph type, as well as unrestricted editing and crossing-free editing.[Settings]- Shows a modal that allows configuring the app to the user's liking. Settings are saved in the browser's localStorage.[Undo/Redo]- Allows moving through the history of changes to the current graph.Resize- Sets up the display so that the current graph takes up the entire canvas area.Expand- Multiplies the coordinates of all vertices by a set factor, only available in edit mode. (e.g. [-1, 4] becomes [-2, 8])Show flips- Draws all possible flips on the current graph, only available in reconfiguration mode.
- 3.3. Right Sidebar:
- 3.3.1. Change History:
- Displays a chronological list of actions performed (e.g., "Add vertex", "Import file", "Add edge").
- Allows navigation through the history using Undo/Redo, as well as jumping to any of the states in the history/undone sections.
- Each entry in the history section stores the state of the graph that occurs after the change that it's describing is applied (indicated by the highlight line appearing under the list item)
- Dynamically updates as you modify the graph.
- 3.3.2. File Contents:
- Shows a live representation of the current graph state in the supported file format.
- Displays Vertex count and Edge count.
- Lists vertex coordinates.
- Lists edge connections (using 1-based indexing).
- Hovering over vertices and edges will highlight them, cliking on a line will select them
- Double-clicking on a line will allow the user to edit it (changing the coordinates of a vertex i.e. which vertices an edge connects)
- Buttons:
- 3.3.1. Change History:
- 3.4. Status Messages:
- Appear in the bottom-left corner of the screen.
- Provide feedback on actions or system status.
- Blue Messages: Informational (e.g., "File imported successfully").
- Red Messages: Indicate errors or problems (e.g., "Graph is not a valid Spanning Tree", "Invalid file format").
- Messages disappear automatically after a few seconds.
You can start with a graph in two ways:
-
- Use the file selector button or drag and drop a valid graph file onto the indicated box.
This is the core feature for exploring graph transformations while maintaining specific structural properties.
- 5.1. Pre-requisite: Valid Graph: Ensure the graph currently displayed in the canvas conforms to the desired graph type (e.g., is a valid Crossing-Free Spanning Tree) before attempting reconfiguration for that type.
- 5.2. Select Graph Type: Choose the graph type you want to work with (toolbar,
graph-mode icon, then click on the desired type). The tool will verify if the current graph matches the selected type. If not, an error message will appear. Note: You can also use keyboard shortcuts to enter these modes.
- 5.3. Initiate reconfigurations: The method depends on the selected graph type:
-
For Perfect Matchings
-
Edge-first Select one existing edge. The tool will highlight existing edges that could potentially be flipped together the selected one while maintaining the graph type. When a second edge is picked, the tool will highlight possible new edges that could be created between the vertices of these 2 old edges. Click one of the new edges to confirm.
-
Vertex-first Select one existing vertex. The tool will highlight existing vertices that could potentially be connected to the selected one, with the complements of each of these 2 also getting connected.
-
-
For All Other Graph Types:
-
Edge-first: Select one existing edge. The tool will highlight possible new edges which could be created, so that the graph type is preserved. Click one of these to confirm and perform the flip.
-
Vertex-first: Select two vertices that do not currently have an edge between them (representing a candidate edge). After selecting the first one, possible candidates for the second one will be highlighted. The tool will then highlight existing edges that could be removed if this candidate edge were added, maintaining the graph type.
-
-
- 5.4. Instant-flip: If the setting is enabled, and the state of the app is such that only 1 flip is possible with a selected edge (i.e. only 1 new edge is possible which preserves the graph type), or with a selected vertex pair (i.e. only 1 existing edge is removable while preserving the graph type), then the app will immediately perform this flip without waiting for user confirmation.
-
6.1. Supported File Format:
- Plain text file. (
.txtusually, but extensions are ignored) - Line 1: Contains two integers:
number_of_verticesnumber_of_edges. - Lines 2 to
number_of_vertices + 1: Each line contains thex ycoordinates for a vertex. - Following
number_of_edgeslines: Each line contains two integersu v, representing the 1-based indices of the vertices connected by an edge.- Note: In each line, the numbers can be separated by whitespace, comma, or semicolon (JS-regex:
/\s|,|;/)
- Note: In each line, the numbers can be separated by whitespace, comma, or semicolon (JS-regex:
Example:
4 3 0 0 10 0 10 10 0 10 1,2 2;3 3 4(This represents a square with 4 vertices and 3 edges connecting V1-V2, V2-V3, V3-V4)
- Plain text file. (
-
6.2. Importing: Use the file input or drag-and-drop (See Section 4.1). Invalid formats will trigger an error message.
-
6.3. Exporting/Viewing: Use the 'File Contents' panel in the right sidebar to view the current graph data, download it as a
.txtfile, or copy it to the clipboard. -
6.4. Your Data Grapher runs entirely in your web browser. Any data you import or otherwise input will not be sent to any server, and no cookies are used.
- Note: The most recent graph is saved to Local Storage as a best-effort means of combatting data loss.
- The "Change History" panel lists all modifications made during the session.
- Use standard keyboard shortcuts to navigate history:
Ctrl+Z(Windows/Linux) orCmd+Z(Mac): Undo the last action.Ctrl+Shift+Z(Windows/Linux) orCmd+Shift+Z(Mac): Redo the last undone action.
- Clicking on history list entries jumps to the state of the graph that ensues after the described change was applied.
The toolbar contains buttons that permit interacting with the program. The main usage is outlined here:
- Undo/Redo button go through History
- Resize canvas coordinates will adjust the zoom and move the view so that the entire current graph appears on the screen
- Explode coordinates will multiply every vertex' coordinates by a fixed amount (by default, 4). This is useful in case the current graph gets too cluttered.
- Change target graph type opens a modal with which the program can be adjusted for specific graph types.
- Standard editing is described in Building a graph
- Non-crossing editing is the same, with the additional rule that crossings can't be created
- The other modes are flip modes, listed under Supported graph types, and described under Performing reconfigurations
- Undo:
Ctrl+Z/Cmd+Z - Redo:
Ctrl+Shift+Z/Cmd+Shift+Z - Delete Selected:
DeleteorBackspace(when a vertex or edge is selected in Edit Mode). - Deselect:
Escape - Clear the file Ctrl+K
- Mode switching
Rfor entering whichever mode is applicable to the current graph type (if any) - so, if the graph is a matching, it will enter matchings mode, and if it's a triangulation, it will enter triangulation mode, etc. Note: Paths will be attempted before trees, because all paths are also trees.Efor entering EDIT modeGfor entering Triangulation mode if possiblePfor entering Paths mode if possibleTfor entering Trees mode if possibleMfor entering Matchings mode if possible
The settings button in the toolbar shows a modal that allows configuring the app to the user's liking. The most important settings appear at the top. This is where the user can turn on or off the displaying of edge intersections, colinear triples of vertices, and the 'instant-flip' feature for reconfuigurations, which will immediately perform a flip as soon as it is unambiguous. The display sizes of certain items are also configurable.
There are other configurable settings, such as the color of displayed items:
- Q: Why can't I import my file?
- A: Check if it strictly follows the format described in Section 6.1. Ensure vertex indices for edges are 1-based, not 0-based. Verify the vertex and edge counts on the first line match the actual data.
- Q: Why does the tool say my graph isn't a valid [Graph Type] when trying reconfiguration?
- A: Ensure your graph strictly meets the definition of the selected type (e.g., a spanning tree must connect all vertices with no cycles, a perfect matching must cover all vertices exactly once, geometry constraints like non-crossing might apply). Correct the graph in Edit Mode first. Worst case, a more useful error message might be logged in the browser console (usually accessed via
F12)
- A: Ensure your graph strictly meets the definition of the selected type (e.g., a spanning tree must connect all vertices with no cycles, a perfect matching must cover all vertices exactly once, geometry constraints like non-crossing might apply). Correct the graph in Edit Mode first. Worst case, a more useful error message might be logged in the browser console (usually accessed via


