The undocumented "CurvedArc"
EdgeShapeFunction
draws edges as curves (instead of straight lines). However, it does not draw arrowheads for directed graphs.
Is there a built-in EdgeShapeFunction
specification that draws directed edges as curved arcs, with a consistent curve direction relative to the edge direction, and visible arrowheads?
I could certainly create my own edge shape function that does this. But this is such a frequently needed edge shape function that I am hoping that it is already built in, just not documented (just like "CurvedArc").
Example of a graph where this would be useful, and CurvedArc fails.
RelationGraph[MemberQ[{1, 2, 4}, Mod[#1 - #2, 7]] &, Range[0, 6],
EdgeShapeFunction -> "CurvedArc"]
Note that this is a directed graph.
Edge shape function that would work better with this graph:
rot[{x_, y_}] := {-y, x}
arc = Function[{pts, edge},
Module[{s = First[pts], t = Last[pts]},
{Arrowheads[{{Automatic, 2/3}}],
Arrow@BezierCurve[{s, s + (t - s)/2 + 1/8 rot[t - s] , t}]}
]
]
All edge shape function specs should be listed by GraphElementData["EdgeShapeFunction"]
but they aren't.
GraphLayout -> "GravityEmbedding"
does this (despite a layout having no business of changing edge shapes...) I just don't know which edge shape spec it uses. $\endgroup$strings
on the kernel library, but unfortunately the edge shape functions aren't clustered near each other so it's too much effort to try and come up with a real list. If it helps,CurvedArc
andCurvedEdge
are the only two I could find that weren't in the list. $\endgroup$TracePrint
+MakeBoxes
on a graph withGraphLayout -> "GravityEmbedding"
shows it's using"CurvedEdge"
. $\endgroup$Show[g] /. bc_BezierCurve :> Arrow[bc]
but that is ugly and makes a Graphics not a Graph $\endgroup$RelationGraph[MemberQ[{1, 2, 4}, Mod[#1 - #2, 7]] &, Range[0, 6], EdgeShapeFunction -> "CurvedEdge"]
? $\endgroup$