GraphTheory - Maple Programming Help

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

GraphTheory

 GetVertexPositions

 Calling Sequence GetVertexPositions(G) GetVertexPositions(G, style=s)

Parameters

 G - graph s - (optional) a style

Description

 • A list of coordinates of the positions of the vertices in the given drawing style. If the vertex positions for the given style are not set before, the empty list is returned.
 • The style s can be any one of fixed, circular, tree, bipartite, spring, planar, user, or default.  If no style is specified, the default drawing style of the graph is used.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $\mathrm{with}\left(\mathrm{SpecialGraphs}\right):$
 > $\mathrm{vp}≔\mathrm{GetVertexPositions}\left(\mathrm{CycleGraph}\left(9\right)\right)$
 ${\mathrm{vp}}{≔}\left[\left[{6.1232340}{}{{10}}^{{-17}}{,}{1.}\right]{,}\left[{0.64278761}{,}{0.76604444}\right]{,}\left[{0.98480775}{,}{0.17364818}\right]{,}\left[{0.86602540}{,}{-0.50000000}\right]{,}\left[{0.34202014}{,}{-0.93969262}\right]{,}\left[{-0.34202014}{,}{-0.93969262}\right]{,}\left[{-0.86602540}{,}{-0.50000000}\right]{,}\left[{-0.98480775}{,}{0.17364818}\right]{,}\left[{-0.64278761}{,}{0.76604444}\right]\right]$ (1)
 > $G≔\mathrm{Graph}\left(\mathrm{Trail}\left(0,1,2,3,4,5,6,7,8,9,1\right),\mathrm{Trail}\left(4,0,7\right)\right)$
 ${G}{≔}{\mathrm{Graph 1: an undirected unweighted graph with 10 vertices and 12 edge\left(s\right)}}$ (2)
 > $\mathrm{SetVertexPositions}\left(G,\left[\left[0,0\right],\mathrm{op}\left(\mathrm{vp}\right)\right]\right):$
 > $\mathrm{DrawGraph}\left(G\right)$

We will disguise the Petersen graph by drawing it using the spring option and make those vertex positions the default.

 > $P≔\mathrm{PetersenGraph}\left(\right)$
 ${P}{≔}{\mathrm{Graph 2: an undirected unweighted graph with 10 vertices and 15 edge\left(s\right)}}$ (3)
 > $\mathrm{DrawGraph}\left(P,\mathrm{style}=\mathrm{spring}\right)$
 > $S≔\mathrm{GetVertexPositions}\left(P,\mathrm{style}=\mathrm{spring}\right)$
 ${S}{≔}\left[\left[{0.966139924305212}{,}{0.124423409473989}\right]{,}\left[{0.671492362648830}{,}{-0.622945284595226}\right]{,}\left[{0.0883553749810576}{,}{-0.911677655976657}\right]{,}\left[{-0.684646177755365}{,}{-0.692940942250190}\right]{,}\left[{0.0914644149940569}{,}{-0.184725679296864}\right]{,}\left[{0.285604708677752}{,}{1.}\right]{,}\left[{0.364102368397874}{,}{0.407906501760275}\right]{,}\left[{-0.268943385452634}{,}{0.543170254501320}\right]{,}\left[{-0.545132908598927}{,}{-0.0422890152843517}\right]{,}\left[{-0.968436682197856}{,}{0.379078411667707}\right]\right]$ (4)
 > $Q≔\mathrm{CopyGraph}\left(P\right)$
 ${Q}{≔}{\mathrm{Graph 3: an undirected unweighted graph with 10 vertices and 15 edge\left(s\right)}}$ (5)
 > $\mathrm{SetVertexPositions}\left(Q,S\right)$
 > $\mathrm{DrawGraph}\left(Q\right)$