This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.

# Graph

 Graphyields a graph with edges . Graphyields the graph with vertices and edges . Graphyields a graph with vertex and edge properties defined by the symbolic wrappers .
• Graph[...] displays in a notebook as a plot of a graph.
• Graph[...] is always converted to an optimized standard form with structure Graph.
• Graph is treated as a raw object by functions like AtomQ, and for purposes of pattern matching.
• An undirected edge between u and v can be given as or UndirectedEdge. The character can be entered as Esc ue Esc.
• A directed edge from u to v can be given as , or DirectedEdge. The character can be entered as Esc de Esc.
• An undirected graph is specified using a collection of undirected edges.
• A directed graph is specified using a collection of directed edges.
• The following special wrappers can be used for vertices and edges:
 Annotation[a,label] provide an annotation Button[a,action] define an action to execute when the element is clicked EventHandler[a,...] define a general event handler for the element Hyperlink[a,uri] make the element act as a hyperlink Labeled[a,...] display the element with labeling PopupWindow[a,cont] attach a popup window to the element StatusArea[a,label] display in the status area when the element is moused over Style[a,opts] show the element using the specified styles Tooltip[a,label] attach an arbitrary tooltip to the element
• Property can be used to associate properties with vertices and edges:
 Property[v,name->value] associate the property with the vertex v Property[e,name->value] associate the property with the edge e
• The following standard properties are supported for vertices:
 VertexLabels labels and label placement for vertex VertexCoordinates center coordinates for vertex VertexShape graphic shape for vertex VertexSize size of vertex VertexStyle style for vertex VertexShapeFunction shape-rendering function for vertex VertexWeight weight for vertex
• The following standard properties are supported for edges:
 EdgeLabels labels for label placement for edge EdgeStyle style for edge EdgeShapeFunction shape-rendering function for edge EdgeWeight weight for edge
• Graph has the same options as Graphics, with the following additions and changes:
 DirectedEdges Automatic whether to interpret Rule as DirectedEdge EdgeLabels Automatic labels and placements for edges EdgeLabelStyle Automatic style to use for edge labels EdgeShapeFunction Automatic generate graphic shapes for edges EdgeStyle Automatic styles for edges EdgeWeight Automatic weights for edges GraphLayout Automatic how to lay out vertices and edges GraphStyle Automatic overall style for graph elements GraphHighlight {} graph elements to highlight GraphHighlightStyle Automatic style for highlight Properties {} properties for graph, edges, and vertices VertexCoordinates Automatic coordinates for vertices VertexLabels Automatic labels and placements for vertices VertexLabelStyle Automatic style to use for vertex labels VertexShape Automatic graphic shape for vertices VertexShapeFunction Automatic generate graphic shapes for vertices VertexSize Medium size of vertices VertexStyle Automatic styles for vertices VertexWeight Automatic weights for vertices
• Properties associates the property etc. with a that can be a vertex, edge, or the graph itself. The following strings for a have special meanings:
 "DefaultEdgeProperties" default edge properties "DefaultVertexProperties" default vertex properties "GraphProperties" properties for the graph itself
• With the setting VertexCoordinates, the placement of vertices and routing of edges is computed automatically based on the setting for GraphLayout.
An undirected graph:
A directed graph:
Style vertices and edges:
Use wrappers to input directly:
Label vertices and edges:
Use different vertices and edges:
An undirected graph:
 Out[1]=

A directed graph:
 Out[1]=

Style vertices and edges:
 Out[1]=
Use wrappers to input directly:
 Out[2]=

Label vertices and edges:
 Out[1]=

Use different vertices and edges:
 Out[1]=
 Out[2]=
 Scope   (27)
Create an undirected graph using characters. Enter the character as Esc ue Esc:
Create a directed graph using characters. Enter the character as Esc de Esc:
Create a directed graph from a list of rules:
Create an undirected graph from a list of rules:
Specify a graph with isolated vertices by giving an explicit list of vertices:
Use VertexList and EdgeList to get vertices and edges:
The ordering for edges is the order in which they were entered:
The ordering for vertices is the order in which they were entered in the edges:
Use an explicit vertex list to control the ordering used by VertexList:
The input vertex list controls the resulting vertex order:
Create undirected or directed graphs with self-loops:
Any expression can be used as vertices:
Use wrappers on vertices or edges:
Wrappers can be nested:
Add interactive behavior by wrappers such as Tooltip:
Any object can be used in the tooltip:
Use Button to trigger actions when clicking an edge or vertex:
Use PopupWindow to provide information drilldown:
Set the style for all vertices or edges:
Style individual vertices or edges using options:
Use wrappers for individual styling:
Adjust the size of vertices using symbolic sizes:
Or use sizes in terms of the smallest distance between vertex centers:
Use built-in collections for VertexShapeFunction:
Rounded shapes:
Concave shapes:
Draw individual vertices:
Combine with a default vertex function:
Use any Graphics, Image, or Graphics3D as a vertex shape:
Use built-in collections for EdgeShapeFunction:
Directed edges including solid arrows:
Line arrows:
Open arrows:
Specify an edge function for an individual edge:
Combine with a different default edge function:
Label any edge or vertex:
Use any expression as a label:
Control the placement of vertex labels using Placed, including symbolic inside positions:
Symbolic outside positions:
Coordinate-based positions:
Place multiple labels using Placed in a wrapper:
Any number of labels can be used:
Place multiple labels using VertexLabels:
Use Placed with symbolic locations to control label placement along an edge:
Use explicit coordinates to place labels:
Place multiple labels using Placed in a wrapper:
Any number of labels can be used:
Place multiple labels using EdgeLabels:
 Options   (82)
By default a directed graph is generated when giving a list of rules:
Use DirectedEdges->False to interpret rules as undirected edges:
Use DirectedEdge or UndirectedEdge to directly specify whether a graph is directed or not:
Label the edge :
Label all edges individually:
Use any expression as a label:
Use Placed with symbolic locations to control label placement along an edge:
Use explicit coordinates to place labels:
Vary positions within the label:
Place multiple labels using Placed in a wrapper:
Any number of labels can be used:
Place multiple labels using EdgeLabels:
Use automatic labeling by values through Tooltip and StatusArea:
Get a list of built-in settings for EdgeShapeFunction:
Undirected edges including the basic line:
Lines with different glyphs on the edges:
Directed edges including solid arrows:
Line arrows:
Open arrows:
Specify an edge function for an individual edge:
Combine with a different default edge function:
Draw edges by running a program:
EdgeShapeFunction can be combined with EdgeStyle:
EdgeShapeFunction has higher priority than EdgeStyle:
Style all edges:
Style individual edges:
EdgeStyle can be combined with EdgeShapeFunction:
EdgeShapeFunction has higher priority than EdgeStyle:
EdgeStyle can be combined with BaseStyle:
EdgeStyle has higher priority than BaseStyle:
Specify a weight for all edges:
Use any numeric expression as a weight:
By default the layout is chosen automatically:
Specify layouts on special curves:
Specify layouts that satisfy optimality criteria:
VertexCoordinates overrides GraphLayout coordinates:
Use AbsoluteOptions to extract VertexCoordinates computed using a layout algorithm:
Highlight the vertex :
Highlight the edge :
Highlight vertices and edges:
Get a list of built-in settings for GraphHighlightStyle:
Use built-in settings for GraphHighlightStyle:
Get a list of built-in settings for GraphStyle:
Use built-in settings for GraphStyle:
Specify a property for vertices:
Edges:
By default any vertex coordinates are computed automatically:
Extract the resulting vertex coordinates using AbsoluteOptions:
Specify a layout function along an ellipse:
Use it to generate vertex coordinates for a graph:
VertexCoordinates has higher priority than GraphLayout:
Use vertex names as labels:
Label individual vertices:
Label all vertices:
Use any expression as a label:
Use Placed with symbolic locations to control label placement, including outside positions:
Symbolic outside corner positions:
Symbolic inside positions:
Symbolic inside corner positions:
Use explicit coordinates to place the center of labels:
Place all labels at the upper-right corner of the vertex and vary the coordinates within the label:
Place multiple labels using Placed in a wrapper:
Any number of labels can be used:
Place multiple labels using VertexLabels:
Use the argument to Placed to control formatting including Tooltip:
Use more elaborate formatting functions:
Use any Graphics, Image, or Graphics3D as a vertex shape:
Specify vertex shapes for individual vertices:
VertexShape can be combined with VertexSize:
VertexShape is not affected by VertexStyle:
VertexShapeFunction has higher priority than VertexShape:
Get a list of built-in collections for VertexShapeFunction:
Use built-in settings for VertexShapeFunction in the collection:
Simple basic shapes:
Common basic shapes:
Use built-in settings for VertexShapeFunction in the collection:
Use built-in settings for VertexShapeFunction in the collection:
Draw individual vertices:
Combine with a default vertex function:
Draw vertices using a predefined graphic:
Draw vertices by running a program:
VertexShapeFunction can be combined with VertexStyle:
VertexShapeFunction has higher priority than VertexStyle:
VertexShapeFunction can be combined with VertexSize:
VertexShapeFunction has higher priority than VertexShape:
By default the size of vertices is computed automatically:
Specify the size of all vertices using symbolic vertex size:
Use a fraction of the minimum distance between vertex coordinates:
Use a fraction of the overall diagonal for all vertex coordinates:
Specify size in both the and directions:
Specify the size for individual vertices:
VertexSize can be combined with VertexShapeFunction:
VertexSize can be combined with VertexShape:
Style all vertices:
Style individual vertices:
VertexShapeFunction can be combined with VertexStyle:
VertexShapeFunction has higher priority than VertexStyle:
VertexStyle can be combined with BaseStyle:
VertexStyle has higher priority than BaseStyle:
VertexShape is not affected by VertexStyle:
Set the weight for all vertices:
Use any numeric expression as a weight:
 Applications   (4)
Build a graph of a finite mapping:
Draw the graph of a random permutation:
Use Table to set similar properties for many items:
Generate a network of "nearby" words in a dictionary:
Use VertexCount and EdgeCount to count vertices and edges:
Use VertexList and EdgeList to enumerate vertices and edges in standard order:
Edges and vertices are given in the order they are input:
Compute the AdjacencyMatrix from a graph:
The row-column ordering is given by VertexList:
New in 8