Constructing and Manipulating Graphs

This Demonstration allows you to create and manipulate any undirected and directed graphs (even including bidirectional arrows and loops).
This is facilitated by a range of edit and display options you can select (such as "distance", i.e., degree of separation).
You can drag the vertices and the connecting edges will follow. You can add and delete, even split and join vertices!
Each vertex and edge can have its own color. Vertices are numbered automatically.
As an application, you are asked to find nice embeddings of five cubic graphs.

(326 lines omitted)

Motivation
While many other Demonstrations exist already relating to two-dimensional graphs, none of them allows you to freely create, color and manipulate graphs.
Basic options
Options "store" and "restore" allow you to keep a backup version of your graph in memory. Note that the default setup is already stored in the backup (hit "clear" and then "restore" to test it).
Hitting "clear" leaves only one vertex.
Options "N","S","E","W" shift the whole graph to the North, South, East or West, one unit at a time.
Option "<" decreases the size of the graph by ten percent; option ">" enlarges it.
You can add a new vertex at any time with Command+Click (Alt+Click on Windows or Option+Click on the Mac). You can also delete an existing vertex with Command+Click!
Warning: do not create new vertices too quickly after each other, since this can lead to system errors.
Option "X" switches the display of the axes on and off.
The drop-down menu "rotate" lets you rotate the graph around the "from" vertex.
Option "directed"
Select "yes" to show arrows. (See "edges" below to find out how to create bidirectional arrows).
Select "highlight bidir" to additionally display all bidirectional arrows in red color.
Notation (option "show numbers")
You can switch the display of the vertex numbers off. You can also select to show the "degrees" of each vertex, which is the number of edges connected to a vertex.
As a third option ("distance"), you can show the graph distance (degree of separation) of each vertex in relation to the selected "from" vertex.
Note that the degree of separation on a directed graph is different from the one on an undirected graph (click "directed" to switch between these cases).
Option "edge" will show the edge numbers at the centre of the edges.
Option "number offset" lets you choose where the notation should be in relation to the vertices and edges (North, South etc).
Automatic color coding
Clicking option "deg v" color-codes all vertices according to their degree, i.e., by the number of edges converging there (degrees 0,1,2,3,4,5,6,>6, correspond to colors red, orange, green, cyan, blue, purple, gray, black).
Option "dist v" color-codes all vertices according to their graph-distance from the "from" vertex (distances 0,1,2,3,4,5,>5,∞ correspond to colors red, orange, cyan,green, blue, purple, gray, black).
Please note that the degree of separation on a directed graph is different from the one on an undirected graph (click "directed" to switch between these cases).
The special case ∞ (color-coded black) denotes all parts of the graph that cannot be reached at all form the "from" vertex.
The option "dist v+e" color-codes all vertices and edges according to their graph-distance from the "from" vertex.
Vertices
Select the correct "from" vertex number to select a vertex.
Color the vertex with the "col" option. Option "c e" re-colors all edges (!) connected to the selected vertex. Option "c r" re-colors all vertices with numbers in the range between "from" and "to". You might have to switch off the automatic color coding (described above) first.
Option "s" splits a vertex into two vertices, with the new vertex having the same connections to other vertices.
Option "u" unites the two vertices selected in "from" and "to", with the new vertex having the sum of the connections.
"del" deletes the selected vertex. Option "d r" deletes all vertices with numbers in the range between "from" and "to".
If you delete a vertex, the remaining vertices are renumbered. For technical reasons you cannot delete the last remaining vertex. Therefore the "clear" option leaves a single vertex at the bottom-left corner.
Edges
Select the correct "from" and "to" vertex numbers to add an edge ("+").
If "from"="to", a little loop will be created. The small loop will be created using the opposite of the "number offset". Hence if "number offset" is S (South), then the loop will be to the North of the vertex. This keeps numbers and loops separate for better readability.
To reverse the direction of an arrow click "r"; to delete an edge click "d".
Clicking "+" for an EXISTING edge switches an arrow from unidirectional to bidirectional and vice versa. (By the way: in directional graphs the edges are called "arcs".)
Option "rf" deletes all edges connected to the "from" vertex.
Option "r*" reverses all edge directions. Note that the direction of an edge is only visible when you select the "directed" option. In this Demonstration either all edges of a graph have directions or none have. A graph with directions is called a directed graph.
Option "c" re-colors the selected edge. You might have to switch off the automatic color coding (described above) first.
Note that coloring of all edges connected to the "from" vertex is covered above in the paragraph "Vertices".
Option "c*" re-colors all edges with the given edge color.
Option "d" deletes the selected edge.
Option "df" deletes all edges connected to the "from" vertex.
Option "dr" deletes all edges converging at any vertex of the selected range 'from',...,'to'.
Add a formation
Often graphs in science are presented as a linear or circular arrangement of vertices. For this reason this Demonstration offers you a convenient tool to create such arrangements with a single mouse click:
The "circles of dots" option creates a circular arrangement of vertices around the "from" vertex.
The "circles with lines" option creates a ring of vertices and edges around the "from" vertex.
The "star" option creates a circular arrangement of vertices around the "from" vertex, where all additional vertices are connected to the central vertex.
Option "complete circle" creates a circular arrangement of vertices around the "from" vertex, where all additional vertices are connected with each other (but not with the center).
Variables "amount" and "radius" define the number of new vertices and their distance from the "from" vertex.
There are several more formations available; try them out!
The special option "complete graph" does NOT add any vertices, it rather adds all missing edges between any existing vertices.
Add a new vertex
You can add a new vertex at any time with Command+Click (Alt+Click on Windows or Option+Click on the Mac).
(You can also delete an existing vertex with Command+Click!)
Several options allow you to connect this new vertex automatically to existing vertices:
In the "connect to" drop-down menu you can choose "last" to automatically connect the new vertex to the "last" vertex created (the one with the highest number), or choose "from" to automatically connect to the "from" vertex or choose "from,to" to connect to both the "from" and "to" vertex. You can also choose to connect to a range of vertices or to all vertices.
Given examples
Graph 1 shows a nice embedding of a cubic graph with six crossings, found by Ed Pegg Jr.
Graphs 2 to 6 show various graphs where you can try to find a nice representation similar to the one given in graph 1 (the graph should be very symmetric or with minimum crossings or both).
Graph 7 is a special default setup (with vertices arranged in two straight lines) that you can use to develop your own graphs. You can create similar setups with the special formation "rectangle".
comments
 
Powered by Wolfram Mathematica
Give us your feedback
Give us your feedback

Source page:




 often  occasionally  never

Note: Please do not include anything you consider confidential or proprietary. Your message and contact information may be shared with the author of any specific Demonstration for which you give feedback, but will not otherwise be published or distributed.
Privacy Policy »

Note: To run this Demonstration you need the free
Mathematica Player
or Mathematica 7+
Download or upgrade to Mathematica Player 7
I already have Mathematica Player or Mathematica 7+