Intractive Graph Layout Method - Maple Help

Interactive Graph Layout Method

Options

 • initial=string
 the name of the initial layout
 • neutral_color=color
 a color specification (see ColorTools/Format) for the unselected vertices in the graph. LightGray by default.
 • select_color=color
 a color specification (see ColorTools/Format) for the selected vertex in the graph. Red by default.
 • drag_color=color
 a color specification (see ColorTools/Format) for the active vertex while dragging in the graph. Yellow by default.
 • nodrag=truefalse
 if the nodrag option is given, only click repositioning will be active in the interactive plot
 • noselect=truefalse
 if the noselect option is given, only drag repositioning will be active in the interactive plot

Description

 • The interactive layout method creates an interactive plot component with a drawing of the Graph that can have the vertices repositioned by click, or clicking and dragging.
 – The first method is to click on a vertex. The vertex will then change to the selection color (red by default). Then click in a new location to reposition the selected vertex, when it will return to the neutral color.
 – The second method is to click and drag a vertex into a new position. When first clicked, the vertex will change to the dragging color (yellow by default). The vertex will return the neutral color when dragging ends.
 • For the interactive layout, all of the graph stylesheet will be preserved except for vertex colors. All vertices will be shown in a neutral color (light gray by default).  This change is not permanent, and is only in effect for the interactive plot.
 • The user layout of the input graph will be continuously updated to reflect changes in the interactive plot so that a bare call to DrawGraph will draw the graph using this layout.
 • This layout method works in two dimensions only.

Examples

Note: To interact with the examples provided below, open this help page as a worksheet and then execute the worksheet.

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $\mathrm{with}\left(\mathrm{RandomGraphs}\right):$
 > $\mathrm{G1}≔\mathrm{RandomGraph}\left(15,26\right)$
 ${\mathrm{G1}}{≔}{\mathrm{Graph 1: an undirected unweighted graph with 15 vertices and 26 edge\left(s\right)}}$ (1)
 > $\mathrm{DrawGraph}\left(\mathrm{G1},\mathrm{layout}=\mathrm{interactive}\right)$

 > $\mathrm{DrawGraph}\left(\mathrm{G1}\right)$

If you are unhappy with your changes and what to start a new interactive layout, with the point layout reset to the default point layout you can specify initial=default in the layout options:

 > $\mathrm{DrawGraph}\left(\mathrm{G1},\mathrm{layout}=\mathrm{interactive},\mathrm{layoutoptions}=\left[\mathrm{initial}=\mathrm{default}\right]\right)$

 > $\mathrm{G2}≔\mathrm{RandomGraph}\left(14,29\right)$
 ${\mathrm{G2}}{≔}{\mathrm{Graph 2: an undirected unweighted graph with 14 vertices and 29 edge\left(s\right)}}$ (2)
 > $\mathrm{DrawGraph}\left(\mathrm{G2},\mathrm{layout}=\mathrm{interactive},\mathrm{layoutoptions}=\left[\mathrm{neutral_color}="White",\mathrm{initial}=\mathrm{spring}\right]\right)$

 > $\mathrm{DrawGraph}\left(\mathrm{G2}\right)$
 >