Skip to main content
4 of 6
added 1293 characters in body
kglr
  • 403.4k
  • 18
  • 501
  • 959

Update: The edge shape function "CurvedArc" has an option "Curvature" that controls the shape of the BezierCurve it produces.

Examples:

Graph[{1 -> 2, 2 -> 3}, VertexCoordinates -> {{0, 0}, {1, 1}, {2, 2}}, VertexLabels -> Placed["Name", Center], VertexSize -> Medium, EdgeShapeFunction -> GraphElementData[{"CurvedArc", "Curvature" -> 2}]] 

Mathematica graphics

Graph[{1 -> 2, 2 -> 3}, VertexCoordinates -> {{0, 0}, {1, 1}, {2, 2}}, VertexLabels -> Placed["Name", Center], VertexSize -> Medium, EdgeShapeFunction -> {(1 -> 2) -> GraphElementData[{"CurvedArc", "Curvature" -> 1}], (2 -> 3) -> GraphElementData[{"CurvedArc", "Curvature" -> -2}]}] 

Mathematica graphics

gr = Graph[{1 -> 2, 1 -> 4, 2 -> 3, 2 -> 5, 3 -> 4, 1 -> 5}, ImagePadding -> 10, VertexCoordinates -> {{0, 0}, {1, 1}, {2, 3}, {4, 1}, {3, 3}}, VertexLabels -> Placed["Name", Center], VertexSize -> Medium, ImageSize -> 500]; gr2 = Fold[SetProperty[{#, #2[[1]]}, {EdgeLabels -> Placed[Style["curvature\n" <> ToString[#2[[2]]], 14], "Middle"], EdgeShapeFunction -> Composition[Style[#, Arrowheads[{{Large, .75}}]] &, Arrow, GraphElementData[{"CurvedArc", "Curvature" -> #2[[2]]}]]}] &, gr, {{1 -> 4, 1.}, {2 -> 5, -.5}, {1 -> 5, .75}, {3 -> 4, -2.5}}]; Row[{gr, gr2}] 

enter image description here


Original post:

There is a built-in EdgeShapeFunction, "CurvedArc", that produces a set of edges that look almost exactly like the ones in @Kuba's answer.

SetProperty[testGraph, EdgeShapeFunction -> "CurvedArc"] 

Mathematica graphics

testGraph2 = EdgeAdd[testGraph, 1 -> 5]; SetProperty[testGraph2, EdgeShapeFunction -> "CurvedArc"] 

Mathematica graphics

Curve only the edges 1 -> 4, 2 -> 5, and 1 -> 5:

Fold[SetProperty[{#, #2}, EdgeShapeFunction -> "CurvedArc"] &, testGraph2, {1 -> 4, 2 -> 5, 1 -> 5}] 

Mathematica graphics

kglr
  • 403.4k
  • 18
  • 501
  • 959