# Is it possible to draw a curved edge between two vertexes of a graph? [duplicate]

The following code generates a graph.

LayeredGraphPlot[
{{"i" -> "m", 1}, {"i" -> "...", 1}, {"i" -> "n", 1}, {"m" -> "j", 2}, {"..." -> "j", 2}, {"n" -> "j", 2}},
DirectedEdges -> True,
VertexLabeling -> True,
PlotStyle -> {FontSize -> 14},
EdgeRenderingFunction -> (Switch[#3, 1, {Dashed, Arrow[#1, .1]}, 2, {Arrow[#1, .1]}] &)] My question is that is it possible to draw curves between "i" and each of "m", "...", "n" instead of straight lines, like the red curve below? Thank you. • You are already using the EdgeRenderingFunction with Arrow. All you need to do is use a function that makes curved lines instead of Arrow. – Szabolcs Dec 28 '14 at 2:54
• @Szabolcs Thanks for the reply. I know there is something like BSplineCurve (reference.wolfram.com/language/ref/Arrow.html), but I don't know how to apply it in this situation. – Tony Dec 28 '14 at 3:01
• Also related: mathematica.stackexchange.com/a/11704/57 – Sjoerd C. de Vries Dec 28 '14 at 11:05
• – István Zachar May 1 '15 at 18:46

You can construct a BezierCurve by adding two control points to the list of vertex coordinates for the two vertices (p[] and p[]) incident to an edge.

In the following function bC with three arguments ({t1,t2,t3}), the two additional points are obtained by taking two points on the line joining the two vertex coordinates, t1 p[] + (1-t1) p[] and t2 p[] + (1-t2) p[] where 0<= t1, t2 <=1, and adding to these points {0,t3} or {t3,0} to ensure that the resulting four points are not collinear. The default values for the three arguments are {t1,t2,t3}= {1/3,2/3,1/3}.

ClearAll[bC]
bC[t1_:(1/3),t2_:(2/3), t3_:(1/3)]:= With[{p=#},
BezierCurve[{p[],
t1 p[]+(1-t1)p[]+If[p[[1,1]]==p[[2,1]],{t3,0},{0,t3}],
t2 p[]+(1-t2)p[]-If[p[[1,1]]==p[[2,1]],{t3,0},{0,t3}],
p[]}]]&;

LayeredGraphPlot[ {{"i" -> "m", 1}, {"i" -> "...", 1}, {"i" -> "n", 1},
{"m" -> "j", 2}, {"..." -> "j", 2}, {"n" -> "j", 2}},
DirectedEdges -> True, VertexLabeling -> True,
PlotStyle -> {FontSize -> 14},
EdgeRenderingFunction -> (Switch[#3, 1, {Dashed,Arrow[bC[][#],.1]}, 2, {Arrow[#1, .1]}] &)] • Why did you reopen this question, please? – Mr.Wizard Apr 8 '15 at 23:00
• @Mr.Wizard, I was puzzling over why this q/a was reopened and appeared with a "modified by kguler" tag. I must have inadvertently clicked the reopen button. Sorry. – kglr Apr 8 '15 at 23:16
• That's okay. It just surprised me as I didn't see any precipitating comments or recent edits. Why don't you close it now? I think this was the previous duplicate if I am reading the timeline correctly. – Mr.Wizard Apr 9 '15 at 0:57
• Mr.Wizard, how come my accidental click made the previous close votes and links disappear? – kglr Apr 9 '15 at 1:01
• You have the Gold tag badge for plotting (and list-manipulation) which gives you moderator-like single vote power to close (and apparently reopen) duplicates in this tag. Use it wisely. :-) (Possible duplicate: comments are automatically deleted when the close occurs.) – Mr.Wizard Apr 9 '15 at 1:22