Skip to main content
deleted 1 character in body
Source Link
kglr
  • 403.4k
  • 18
  • 501
  • 959
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, -0.5}, {1 -> 5, .75}, {3 -> 4, -2.5}}]; Row[{gr, gr2}] 

enter image description hereenter image description here

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

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, 0.}, {1 -> 5, .75}, {3 -> 4, -2.5}}]; Row[{gr, gr2}] 

enter image description here

added 6 characters in body
Source Link
kglr
  • 403.4k
  • 18
  • 501
  • 959
Graph[{1 -> 2, 2 -> 3, 1->3}, VertexCoordinates -> {{0, 0}, {1, 1}, {2, 2}}, VertexLabels -> Placed["Name", Center], VertexSize -> Medium, EdgeShapeFunction -> GraphElementData[{"CurvedArc", "Curvature" -> 2}]] 

Mathematica graphicsMathematica graphics

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, 1->3}, VertexCoordinates -> {{0, 0}, {1, 1}, {2, 2}}, VertexLabels -> Placed["Name", Center], VertexSize -> Medium, EdgeShapeFunction -> GraphElementData[{"CurvedArc", "Curvature" -> 2}]] 

Mathematica graphics

added 1293 characters in body
Source Link
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.

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

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.

added 148 characters in body
Source Link
kglr
  • 403.4k
  • 18
  • 501
  • 959
Loading
added 148 characters in body
Source Link
kglr
  • 403.4k
  • 18
  • 501
  • 959
Loading
Source Link
kglr
  • 403.4k
  • 18
  • 501
  • 959
Loading