Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I try to plot a 3-cycle, the edge direction is always counter-clockwise. The plotting code is

GraphPlot[{1 -> 0, 0 -> 2, 2 -> 1}, VertexLabeling -> True, 
 DirectedEdges -> True, PlotStyle -> {FontSize -> 13}, 
 VertexRenderingFunction -> ({EdgeForm[White], 
     RGBColor[113/255, 190/255, 236/255], Disk[#1, 0.15], White, 
     Text[#2, #1]} &)]

and the output

enter image description here

I have tried many ways to change the edge direction without success. Anyone can help with this? Thank you!

share|improve this question

You can use the option VertexCoordinateRules:

opts = {VertexLabeling -> True, DirectedEdges -> True, 
   VertexCoordinateRules -> {{0., 1.}, {1., 1.}, {.5, 0.}}, 
   PlotStyle -> {FontSize -> 13}, 
   VertexRenderingFunction -> ({EdgeForm[White], 
       RGBColor[113/255, 190/255, 236/255], Disk[#1, 0.15], White, 
       Text[#2, #1]} &)};
GraphPlot[{1 -> 0, 0 -> 2, 2 -> 1}, opts]

Mathematica graphics

Or use Graph and give the vertices in the order you wish as the first argument:

opts2 = {VertexSize -> Medium,
   VertexStyle -> 
    Directive[EdgeForm[White], RGBColor[113/255, 190/255, 236/255]], 
   VertexLabels -> Placed["Name", Center], 
   VertexLabelStyle -> {Directive[White, FontSize -> 16]}, 
   VertexShapeFunction -> "Circle"};
Graph[{0, 1, 2}, {1 -> 0, 0 -> 2, 2 -> 1}, opts2]

Mathematica graphics

share|improve this answer

Simply as an alternative you can interactively rearrange the nodes, but to do so you must avoid VertexRenderingFunction. Here is an example:

postLabel[f_] := Text[Framed[n_, __], p_] :> f[p, n]

labelFn = {EdgeForm[White], RGBColor[113/255, 190/255, 236/255], Disk[#1, 0.15], White, 
    Text[#2, #1]} &;

GraphPlot[{1 -> 0, 0 -> 2, 2 -> 1}, VertexLabeling -> True, DirectedEdges -> True, 
  PlotStyle -> {FontSize -> 13}] /. postLabel[labelFn]

You can then click as necessary to enter the graphic and select a node, then drag to rearrange as desired. Example result:

enter image description here

Reference: http://stackoverflow.com/a/8109449/618728

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.