4
$\begingroup$

I have a desired graph as here: the dashed line is just for perspective representation. I tried with LayeredGraphPlot and GraphPlot3D but I don't know how I can show perceptively in 3 dimensions with LayeredGraphPlot or a curved lines in GraphPlot3D.

The scales in schematic picture are completely arbitrary but in order to achieve the graph, also showing the axes of coordinators are not needed, I should have presented here to be more clear! and stacking i ,j, k, l, m, n on the vertex (small circle on shape) can be desired.

enter image description here

For version 10: here is a problem at which I have encountered in running the David G.Stork code:

enter image description here

For version 9: although I don't write show in the last line but I just want to present the problem is related to create graph!

ef[pts_List, e_] := {Arrowheads[{0, .05, 0}], 
Arrow[BezierCurve[{pts[[1]], pts[[1]] + {0, 0, 1}, 
  pts[[2]] + {0, 0, 1}, pts[[2]]}]]};

myfig = Graph[{Style[1 -> 2, Thickness[0.005], Yellow], 
  Style[1 -> 4, Yellow, Dashing[0.02]], Style[1 -> 6, Yellow], 
   Style[2 -> 3, Green], Style[3 -> 4, Green], Style[4 -> 5, Green], 
   Style[5 -> 6, Green]}, EdgeShapeFunction -> ef, 
  VertexCoordinates -> {1 -> {2, 0, 1}, 2 -> {0, 0, 0}, 
   3 -> {1, -1, 0}, 4 -> {2, -1, 0}, 5 -> {3, -1, 0}, 
   6 -> {4, 0, 0}}, Background -> LightGray]

But the output will be as below (just for showing output) enter image description here

$\endgroup$
  • $\begingroup$ Try with Graphics3D[ ] instead $\endgroup$ – Dr. belisarius Dec 1 '15 at 21:00
  • $\begingroup$ I can't curve smoothly lines in Graphics3D, they are sharply curved! $\endgroup$ – monfneg Dec 1 '15 at 21:10
11
$\begingroup$
ef[pts_List, e_] :=
  {Arrowheads[{0, .05, 0}],
   Arrow[
    BezierCurve[
     {pts[[1]],
      pts[[1]] + {0, 0, 1},
      pts[[2]] + {0, 0, 1}, 
      pts[[2]]}]]};

myfig = Graph[
  {Style[1 -> 2, Thickness[0.005], Yellow], 
   Style[1 -> 4, Yellow, Dashing[0.02]], Style[1 -> 6, Yellow], 
   Style[2 -> 3, Green], Style[3 -> 4, Green], Style[4 -> 5, Green], 
   Style[5 -> 6, Green]},

  EdgeShapeFunction -> ef,

  VertexCoordinates -> {1 -> {2, 0, 1},
    2 -> {0, 0, 0},
    3 -> {1, -1, 0},
    4 -> {2, -1, 0},
    5 -> {3, -1, 0},
    6 -> {4, 0, 0}},
  Background -> LightGray];

Show[myfig,
 Graphics3D[
  {Arrow[{{0, 0, 0}, {5, 0, 0}}],
   Arrow[{{0, 0, 0}, {0, -3, 0}}],
       Arrow[{{0, 0, 0}, {0, 0, 3}}],
   {Dashed, Line[{{0, -1, 0}, {5, -1, 0}}]}}
  ]]

enter image description here

$\endgroup$
  • $\begingroup$ So much thanks, Although I can understand most of the process of your code but I can't re construct your shape. I encounter to this message: Objects of "unequal length in {2.,0.}+{0,0,1} cannot be combined", "Objects of unequal length in {0.,0.}+{0,0,1} cannot be combined" ,"Objects of unequal length in {2.,0.}+{0,0,1} cannot be combined"!!! $\endgroup$ – monfneg Dec 2 '15 at 2:16
  • $\begingroup$ Your vertex coordinates must be three-dimensional, i.e., {0,0,0} and {1, -1, 0}. You should just copy my code and run it directly. $\endgroup$ – David G. Stork Dec 2 '15 at 2:32
  • $\begingroup$ I just copy your code and run. because I can't upload a picture in comment, I am uploading that in the main question. please take a look at that. $\endgroup$ – monfneg Dec 2 '15 at 3:11
  • $\begingroup$ @user36028 - start with a fresh kernel. $\endgroup$ – Bob Hanlon Dec 2 '15 at 4:02
  • $\begingroup$ I started a fresh kernel! I even use of version 9, however the previous message does not appear again but another surprising message appears I upload that $\endgroup$ – monfneg Dec 2 '15 at 4:41

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.