GraphTheory - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Discrete Mathematics : Graph Theory : GraphTheory Package : GraphTheory/DrawGraph

GraphTheory

  

DrawGraph

  

draw a graph stored in the Graph data structure

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

DrawGraph(G, options)

DrawGraph(L, options)

Parameters

G

-

graph

L

-

list or set of graphs

options

-

(optional) zero or more options as specified below

Options

  

The options argument can contain one or more of the options shown below. In addition, DrawGraph accepts those options listed on plot,options for 2-D visualizations and those options listed on plot3d,option for 3-D visualizations.

• 

animate=truefalse

  

If the style=spring or style=spring[constant] option is specified then animate=true will cause a 50 frame animation of the model to be generated. The default is false.

• 

dimension=2 or 3

  

The number of dimensions in the generated plot.

• 

redraw:truefalse

  

If the style=spring or style=spring[constant] option is specified then redraw=true will cause the graph to be redrawn using a different random starting position. The default is false.

• 

root=v

• 

If the style=tree drawing option is specified then G must be undirected or an arborescence per IsArborescence. If G is undirected and not a tree, its SpanningTree will be used to determine the location of its vertices, but all of the edges of G will be drawn. The additional optional argument root=v may be specified to specify the root vertex v. The value v must be a vertex in G.

• 

showlabels=truefalse

  

The display of vertex labels may be forced or suppressed with the option showlabels=true and showlabels=false, respectively. By default, the vertex labels are displayed when G has fewer than 100 vertices.

• 

showweights=truefalse

  

The display of edge weights may be forced or suppressed with the option showweights=true and showweights=false, respectively. By default, the edge weights are displayed when G is a weighted graph with fewer than 46 edges.

• 

style=bipartite, circle, planar, spring, spring[constant], or tree.

  

The style option directs DrawGraph to display the input graph in a specific style. There are five different styles supported for displaying a graph: bipartite, circle, planar, spring, and tree.

  

All components of a disconnected graph are detected and are displayed separately.  The type of each graph or a component of a disconnected graph is distinguished and is displayed accordingly.

  

The style=spring option is so named because it simulates a physical model where the vertices are modeled as protons repelling each other and the edges are modeled as springs attracting adjacent vertices. This leads to a dense system of nonlinear ODEs to be solved and so this option becomes quite expensive beyond 100 vertices. At present the spring option requires that the graph be connected and it does not display edge weights in three dimensions.

  

The spring[constant] style uses a pure constant repulsive force for the vertices. This style is equivalent to spring for Maple 15 and earlier versions. The default is a combined model that initially integrates the ODE using a constant force model, then shifts to use of an inverse square law repulsive force.

• 

stylesheet=list

• 

The colors, line weights, and font choices can be specified with the stylesheet option which is detailed in GraphTheory/GraphDrawingOptions.

  

Specifying stylesheet="legacy" displays the graph with the default settings for Maple 2016 and previous versions. Animations and 3-D graph renderings currently do not support the stylesheet option.

Description

• 

DrawGraph displays the vertices and edges of a graph G as a Maple plot. If G has fewer than 100 vertices, the vertex labels are also displayed. If G is a weighted graph with fewer than 46 edges then the edge weights are displayed.

• 

The colors, line weights, and font choices can be specified with the stylesheet option, detailed in GraphTheory/GraphDrawingOptions. Animations and 3-D graph renderings do not currently support the stylesheet option.

• 

By default, the vertex positions for paths, cycles, cliques and most of the graphs in the SpecialGraphs, such as the Petersen graph, have been predefined, so that when displayed, they appear as they would in a textbook.  You may specify the vertex positions for the display of a graph using the SetVertexPositions command.

• 

You may set individual vertex and edge colors using the HighlightVertex and HighlightEdges commands.  You may set vertex and edge colors of a subgraph of G using the HighlightSubgraph command, and set edge colors of a trail, path or cycle of G using the HighlightTrail command.

• 

If G is a set or list of graphs, then the graphs are displayed in a Matrix format, where any leftover cells are simply displayed as empty. The number of graphs to display horizontally is chosen as a value between 2 and 4 determined by the number of graphs in the input list. This can be overridden by providing the width option to tell DrawGraph the number of graphs to display horizontally. For example, specify width=1 to display the graphs in one long vertical band, and specify width=nops(G) to display the graphs in one wide horizontal band.

Examples

withGraphTheory:

withSpecialGraphs:

withRandomGraphs:

GGraphundirected,1,2,2,3,3,4,4,1

GGraph 1: an undirected unweighted graph with 4 vertices and 4 edge(s)

(1)

DrawGraphG

FGraph6,undirected,1,2,2,3,5,6

FGraph 2: an undirected unweighted graph with 6 vertices and 3 edge(s)

(2)

DrawGraphF

CGraphdirected,1,2,2,3,3,4,4,1

CGraph 3: a directed unweighted graph with 4 vertices and 4 arc(s)

(3)

DrawGraphC

DrawGraphC,style=circle

WMatrix0,2,3,1,2,0,4,1,3,4,0,5,6,2,5,0

0231204134056250

(4)

GGraphdirected,weighted,W

GGraph 4: a directed weighted graph with 4 vertices and 12 arc(s)

(5)

DrawGraphG

K33CompleteGraph3,3

K33Graph 5: an undirected unweighted graph with 6 vertices and 9 edge(s)

(6)

DrawGraphK33,style=bipartite

TSpanningTreeK33

TGraph 6: an undirected unweighted graph with 6 vertices and 5 edge(s)

(7)

DrawGraphT,style=tree,root=2

HighlightEdgesK33,T,Red

DrawGraphK33

PPetersenGraph

PGraph 7: an undirected unweighted graph with 10 vertices and 15 edge(s)

(8)

DrawGraphP

DrawGraphP,style=spring

DrawGraphP,style=spring,redraw

To play the following animation in this help page, right-click (Control-click, on Macintosh) the plot to display the context menu.  Select Animation > Play.

DrawGraphP,style=spring,animate=true

The commands to create the plots from the Plotting Guide are

HHypercubeGraph3

HGraph 8: an undirected unweighted graph with 8 vertices and 12 edge(s)

(9)

DrawGraphH

DrawGraphH,style=spring,dimension=3

IsHamiltonianH,'cycle'

true

(10)

cycle

000,100,110,010,011,111,101,001,000

(11)

HighlightTrailH,cycle,Red

DrawGraphH

TRandomTree100

TGraph 9: an undirected unweighted graph with 100 vertices and 99 edge(s)

(12)

DrawGraphT

SSoccerBallGraph

SGraph 10: an undirected unweighted graph with 60 vertices and 90 edge(s)

(13)

DrawGraphS

DrawGraphS,style=spring,dimension=3

Compatibility

• 

The GraphTheory[DrawGraph] command was updated in Maple 2017.

• 

The stylesheet option was introduced in Maple 2017.

• 

For more information on Maple 2017 changes, see Updates in Maple 2017.

See Also

DrawNetwork

HighlightEdges

HighlightSubgraph

HighlightTrail

HighlightVertex

RandomGraphs

SpecialGraphs