Wolfram ResearchProductsPurchasingServices & ResourcesAbout UsOur Sites
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.

DiscreteMath`GraphPlot

DiscreteMath`GraphPlot provides functions for aesthetic straight-line drawing of graphs. The package also contains a number of functions useful for graph theory applications. The functions are designed to work efficiently for very large graphs.

In this package, a graph is represented by its adjacency matrix. Graphs from the Combinatorica package are also supported, as are graphs specified by a rule list.

Graph drawing functions.

This loads the package.

In[1]:=

This plots a graph specified by a rule list.

In[2]:=

GraphPlot and GraphPlot3D work with disconnected graphs. The individual components are laid out in a visually appealing way.

In[3]:=

GraphPlot and GraphPlot3D are designed to work with very large graphs. This plots a graph of 1005 vertices defined by a matrix from a structural engineering application.

In[5]:=
In[6]:=

GraphPlot and GraphPlot3D accept the following options, as well as options for Graphics and Graphics3D.

Options for GraphPlot and GraphPlot3D.

This imports a data set and draws the graph in blue, using the spring model method.

In[7]:=

Graph drawing functions that return coordinates.

This plots a graph.

In[9]:=

This gives the coordinates of the vertices in the previous drawing.

In[11]:=
Out[11]=

GraphCoordinates and GraphCoordinates3D accept the following options.

Options for GraphCoordinates and GraphCoordinates3D.

This gives the coordinates using the spring model method.

In[12]:=
Out[12]=

The TreePlot function.

This plots a binary tree.

In[13]:=

TreePlot accepts the following options, as well as options for Graphics.

Options for TreePlot.

This plots the previous tree but with the root in the center.

In[15]:=

Calculating graph distance and diameter.

This plots a graph of 37 vertices.

In[16]:=

This calculates the pseudo-diameter of the graph. The graph is first converted to an undirected graph, because PseudoDiameter takes an undirected graph as input. The calculation finds that the diameter 6 is achieved between vertices 1 and 25.

In[17]:=
Out[18]=

This confirms that the distance between vertices 1 and 25 is indeed 6.

In[19]:=
Out[19]=

Finding a maximal matching, a maximal independent vertex set, and a maximal independent edge set.

For a matrix of dimension  , the bipartite graph consists of vertex sets  and  , where two vertices  and  are connected if the matrix element  .

This shows that, for the following bipartite graph, row 1 is matched to column 2, row 3 is matched to column 2, and row 2 is matched to column 3.

In[20]:=
Out[20]=

For an undirected graph, an independent vertex set is a set of vertices such that no two vertices in the set share an edge. A maximal independent vertex set is an independent set such that adding another vertex will make it no longer independent.

This shows that for an undirected graph of four vertices linked in a square, a maximal independent vertex set consists of two vertices at diagonally opposite corners.

In[21]:=
Out[21]=

A maximal independent edge set of this graph has two edges opposite one another.

In[22]:=
Out[22]=

Finding strongly connected components.

A strongly connected component in a directed graph is a set of vertices such that there is a path between any two vertices in the set.

This shows that in a directed graph of three nodes ordered in a circular fashion, the strongly connected component contains all the vertices.

In[23]:=
Out[23]=

Finding a mincut.

This shows a graph of 6 vertices.

In[24]:=

This shows the best partitioning of the graph into two parts. This partitioning only cuts through one edge, between vertices 2 and 4.

In[25]:=
Out[25]=

Getting a list of all vertices.

This function is particularly useful for graphs specified using a rule list.

This specifies a graph using a rule list.

In[26]:=

This gives the list of vertices.

In[28]:=
Out[28]=

For further information, see the Advanced Documentation for GraphPlot.


Any questions about topics on this page? Click here to get an individual response.Buy NowFree TrialMore Information



 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: