Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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]} &)]
share|improve this question
1  
Highly related (if not duplicate): Manipulate Graphs. –  István Zachar Dec 9 '13 at 21:06

2 Answers 2

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

share|improve this answer
    
How do I do deal with the situation that there is a rendered label on top of the vertex? –  Tyler Durden Dec 10 '13 at 0:53
    
How are you rendering the label? –  bill s Dec 10 '13 at 1:06
    
I have updated the post to show the rendering code. –  Tyler Durden Dec 10 '13 at 1:14
    
I guess the answer is the same: you can move the labels independently of the vertices, the circles, and the numbers. –  bill s Dec 10 '13 at 1:22

You may try:

Needs["GraphUtilities`"]
GraphEdit[Table[i -> Mod[i^3, 27], {i, 0, 27}]]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.