5
$\begingroup$

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]} &)]
$\endgroup$
1
6
$\begingroup$

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

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

You may try:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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