Function Repository Resource:

DragGraphVertices

Source Notebook

Dynamically drag around the vertices of a graph

Contributed by: Nikolay Murzin

ResourceFunction["DragGraphVertices"][g]

makes an interactive graphics of a graph g with draggable vertices.

ResourceFunction["DragGraphVertices"][Dynamic[g]]

creates a dynamic control that modifies graph g.

Details and Options

Without a Dynamic wrapper, the modified graph would be stored in the newly created global unique $DragGraphVerticesGraphXXXX variables, where XXXX is a unique integer.

Examples

Basic Examples (1) 

Drag around graph vertices:

In[1]:=
ResourceFunction["DragGraphVertices"]@RandomGraph[{8, 16}]
Out[1]=

Scope (1) 

Modify an existing graph using Dynamic wrapper:

In[2]:=
graph = RandomGraph[{8, 16}]
Out[2]=
In[3]:=
ResourceFunction["DragGraphVertices"][Dynamic[graph]]
Out[3]=
In[4]:=
{ResourceFunction["DragGraphVertices"][Dynamic[graph]], Dynamic[graph]}
Out[4]=

Options (2) 

DragGraphVertices accepts LocatorPane options:

In[5]:=
ResourceFunction["DragGraphVertices"][RandomGraph[{8, 16}], Appearance -> Automatic]
Out[5]=

DragGraphVertices accepts Graph options:

In[6]:=
ResourceFunction["DragGraphVertices"][RandomGraph[{8, 16}], VertexLabels -> Automatic]
Out[6]=

Version History

  • 1.0.0 – 20 December 2021

License Information