Skip to content

A react application for visualizing how graph algorithms work.

Notifications You must be signed in to change notification settings

glynfinck/graph-editor-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graph Editor Documentation

This documents explains how to use the Graph Editor web application.

Table of Contents

  1. Getting Started
  2. Notes on Usage
  3. Editor
  4. Graph
  5. Dependencies

Getting Started

The easiest way to use this application is to pull the docker image on DockerHub using the following command:

docker pull glynfinck/graph-editor-react

After pulling the image, run the following command and the application should be available at localhost:80:

docker run -p 80:80 -d glynfinck/graph-editor-react

Notes on Usage

  • The graph is treated as un-directed by default (no support for directed graph so far, this will be added in the future)
    • If edge (A -> B) exists then edge (B -> A) exists and vice versa.
  • There currently is no support for mobile devices at the moment (this feature will come in the future)

Editor

Graph Class

Set Current Node

setCurrentNode(id, peek=False, path=False)

Setting the current node will give a red border around the node chosen using id and will make the fill of the node blue. Setting the current node will automatically un-set the previous current node/edge removing the red border. This alows the user to automatically keep track of visited nodes/edges while also showing the current node as well.

If the optional parameter peek is set to True then the node with id equal to id will not be set to blue and will remain white.

If the optional parameter path is set to True the node with id equal to id will be set to yellow instead of blue. This is used to indicate a path being found instead of one of the visited nodes/edges.

Usage

The following string of commands showcases how the method can be used.

g = Graph()
g.setCurrentNode("A")
g.setCurrentNode("B", peek=True)
g.setCurrentNode("C", path=True)
g.setCurrentNode("D", peek=True, path=True)

Producing the following result in our graph:

Set Current Edge

setCurrentEdge(source_id, target_id, peek=False, path=False)

Setting the current edge will give a red border around the edge chosen using source_id and target_id and will make the fill of the edge blue. Setting the current node will automatically un-set the previous current node/edge removing the red border. This alows the user to automatically keep track of visited nodes/edges while also showing the current edge as well.

If the optional parameter peek is set to True then the edge chosen using source_id and target_id will not be set to blue and will remain white.

If the optional parameter path is set to True the edge chosen using source_id and target_id will be set to yellow instead of blue. This is used to indicate a path being found instead of one of the visited nodes/edges.

Usage

The following string of commands showcases how the method can be used.

g = Graph()
g.setCurrentEdge("A","B")
g.setCurrentEdge("B","C", peek=True)
g.setCurrentEdge("C","D", path=True)
g.setCurrentEdge("D","A", peek=True, path=True)

Producing the following result in our graph:

Get Neighbors of a Node

getNeighbors(id)

Returns all neighbors for a node with id.

Usage

For the following graph and input:

g = Graph()
neighbors = g.getNeighbors("A")
print(neighbors)

We get the following output:

{'C': {}, 'B': {}, 'D': {}}

Get All Nodes

getNodes()

Returns all nodes in the graph.

Usage

For the following graph and input:

g = Graph()
nodes = g.getNodes()
print(nodes)

We get the following output:

[('A', {}), ('B', {}), ('C', {}), ('D', {})]

Get All Edges

getEdges()

Returns all edges in the graph.

Usage

For the following graph and input:

g = Graph()
edges = g.getEdges()
print(edges)

We get the following output:

[('A', 'C', {}), ('A', 'B', {}), ('A', 'D', {}), ('B', 'C', {}), ('B', 'D', {})]

Has Node

hasNode(id)

Will return True if the node with id equal to id is in the graph and False otherwise.

Has Edge

hasNode(source_id, target_id)

Will return True if the node with source id equal to source_id and target id equal to target_id and False otherwise.

Graph

Creating Nodes

To create a node hold down SHIFT and then click on an empty area of the graph as shown above.

Creating Edges

To create an edge between two nodes hold down SHIFT and drag from the source node to the target node as shown above.

Deleting Nodes

To delete nodes CLICK on the node you want to delete and press the DELETE the key. Edges connected to the deleted node will automatically be deleted as well.

Deleting Edges

To delete edges CLICK on the edge you want to delete and press the DELETE the key.

Dependencies

Styling/Layout

Graph

Editor

Python Webworker

About

A react application for visualizing how graph algorithms work.

Resources

Stars

Watchers

Forks

Packages

No packages published