Interactive Graph Layout Method
Options
Description
Examples
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
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.
Note: To interact with the examples provided below, open this help page as a worksheet and then execute the worksheet.
with⁡GraphTheory:
with⁡RandomGraphs:
G1≔RandomGraph⁡15,26
G1≔Graph 1: an undirected graph with 15 vertices and 26 edge(s)
DrawGraph⁡G1,layout=interactive
DrawGraph⁡G1
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:
DrawGraph⁡G1,layout=interactive,layoutoptions=initial=default
G2≔RandomGraph⁡14,29
G2≔Graph 2: an undirected graph with 14 vertices and 29 edge(s)
DrawGraph⁡G2,layout=interactive,layoutoptions=neutral_color=White,initial=spring
DrawGraph⁡G2
See Also
GraphTheory[DrawGraph]
Download Help Document