Manually adjust graph vertex location by dragging?

4

1

Sometimes I have a graph and I want to make tweaks to the vertex locations. Is there any way to manually adjust graph vertex location by dragging?

If I double click to edit, I can move around the vertex rendered shape (square) or the label inside the square, but not the vertex itself. Also, even if I could move the vertex, it is under the rendered square/circle which does not seem to move with it.

I have been using GraphPlot. (Should I be using Graph instead? I don't really understand the difference.):

GraphPlot[Import["D:/dev/ProjectEuler/keylog.gv"], 
 VertexLabeling -> True, PlotStyle -> {Black}, 
 VertexRenderingFunction -> ({EdgeForm[Black], White, Disk[#1, 0.08], 
     Black, Text[#2, #1]} &)]

Tyler Durden

Posted 2013-12-09T19:54:39.597

Reputation: 3 808

1

Highly related (if not duplicate): Manipulate Graphs.

– István Zachar – 2013-12-09T21:06:12.440

Answers

6

You can change the locations of the vertices by double clicking on them and dragging. For example:

GraphPlot[{1 -> 2, 2 -> 3, 3 -> 4, 4 -> 5, 5 -> 1}]

enter image description here

After double clicking and dragging two of the vertices:

enter image description here

If you have labels and ornaments on the vertices, then you can move them independently. For example, after moving two of the circles, numbered labels, and vertices:

GraphPlot[{1 -> 2, 2 -> 3, 3 -> 4, 4 -> 5, 5 -> 1}, PlotStyle -> {Black}, 
VertexRenderingFunction->({EdgeForm[Black],White,Disk[#1, 0.08],Black,Text[#2,#1]} &)]

enter image description here

bill s

Posted 2013-12-09T19:54:39.597

Reputation: 62 963

How do I do deal with the situation that there is a rendered label on top of the vertex? – Tyler Durden – 2013-12-10T00:53:52.010

How are you rendering the label? – bill s – 2013-12-10T01:06:00.237

I have updated the post to show the rendering code. – Tyler Durden – 2013-12-10T01:14:36.177

I guess the answer is the same: you can move the labels independently of the vertices, the circles, and the numbers. – bill s – 2013-12-10T01:22:36.277

2

You may try:

Needs["GraphUtilities`"]
GraphEdit[Table[i -> Mod[i^3, 27], {i, 0, 27}]]

Dr. belisarius

Posted 2013-12-09T19:54:39.597

Reputation: 112 848