4
$\begingroup$

Bug introduced in 10.0 and fixed in 11.3.0.
Graph3D is new in 10.0


I tried to visualize a simple graph and unexpectedly Graph3D produced a double arrow for multi-edges in the 3rd dimension:

Graph3D[
 {0,1,2,3},
 DirectedEdge@@@{{0,1},{1,0},{0,2},{2,0},{1,3},{3,1},{2,3},{3,2}},
 VertexLabels->"Name",VertexLabelStyle->White,
 VertexCoordinates->{{0,0,0},{0,0,1},{0,1,0},{0,1,1}},
 Background->Black
]

graph1

Multi-edges in the 1st and 2nd dimension are rendered correctly with two separate arrows

Graph3D[
 {0,1,2,3},
 DirectedEdge@@@{{0,1},{1,0},{0,2},{2,0},{1,3},{3,1},{2,3},{3,2}},
 VertexLabels->"Name",
 VertexCoordinates->{{0,0,0},{0,1,0},{1,0,0},{1,1,0}},
 Background->Black
]

graph2

Please help me understand this behavior. I would like my graph to have seperate arrows for all multi-edges.

$\endgroup$
  • 2
    $\begingroup$ This may be a bug. The edges are definitely there, but MMA put them on top of each other. It works fine if you do NOT specify the VertexCoordinates. $\endgroup$ – JEM_Mosig Jun 29 '17 at 9:37
2
$\begingroup$

A workaround: Use a custom EdgeShapeFunction to modify the shapes of selected edges (0->1 and 2->3) using SetProperty:

edgeShape = Module[{g = #, vs = VertexList[{#2}], p}, 
  pos = N[PropertyValue[{g, #}, VertexCoordinates]&/@vs]; 
  Cases[Show[g][[1]], ar : Arrow[Tube[BezierCurve[{p[[1]], a_, p[[2]]}]],___] :> 
  (ar/. a->({-1, 1, 1}a)), Infinity]]&;

g0 = Graph3D[{0,1,2,3}, 
 DirectedEdge @@@ {{0, 1}, {1, 0}, {0, 2}, {2, 0}, {1, 3}, {3, 1}, {2, 3}, {3, 2}},
 VertexLabels -> "Name", VertexLabelStyle -> White,
 VertexCoordinates->{{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {0, 1, 1}}, Background->Black]

Fold[Module[{es = edgeShape[##]}, 
 SetProperty[{##}, EdgeShapeFunction -> (es&)]]&, 
  g0, {DirectedEdge[1, 0], DirectedEdge[2, 3]}]

enter image description here

$\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.