Graph Untangler

Adam Rumpf, 2/5/2016

Introduction

This is a small, lightweight program that lets the user define a graph and then click and drag to move the vertices. This may be useful for manipulating the appearance of a graph to see whether it is isomorphic to another graph.

The graphmove[] function accepts a Graph object as its input. The initial embedding arranges the vertices into a unit circle in an arbitrary order.

Code

Initialization

graphmove[g_]:=Quiet[Module[{n=Length[AdjacencyMatrix[g]]},
Manipulate@@Join[{GraphPlot[g,VertexCoordinateRules->Table[i->a[i],{i,1,n}],PlotRange->{{-1.1,1.1},{-1/1,1.1}}]},Table[{{a[i],{Cos[2Pi i/n],Sin[2Pi i/n]}},Locator},{i,1,n}]]
]]

Demonstration

(* Manipulating a built-in graph *)
graphmove[PetersenGraph[5,2]]

(* Manipulating a user-defined graph *)
g1=Graph[{1\[UndirectedEdge]4,1\[UndirectedEdge]6,1\[UndirectedEdge]8,3\[UndirectedEdge]2,3\[UndirectedEdge]6,3\[UndirectedEdge]8,5\[UndirectedEdge]2,5\[UndirectedEdge]4,5\[UndirectedEdge]8,7\[UndirectedEdge]2,7\[UndirectedEdge]4,7\[UndirectedEdge]6}];
graphmove[g1]