is an option and annotation for Graph and related functions that specifies a function to use to generate primitives for rendering each edge.
EdgeShapeFunction
is an option and annotation for Graph and related functions that specifies a function to use to generate primitives for rendering each edge.
Details
- EdgeShapeFunction is also known as edge routing.
- EdgeShapeFunction is typically used to control the visual appearance of paths connecting vertices.
- The following option settings can be used:
-
Automatic the default edge function None do not render edges "nfunc" a named edge function func a general edge function {vivj->efij,…} use edge function efij for edge vivj {pattiefi,…} use edge function efi for edges matching the pattern patti - EdgeShapeFunction->func specifies that each edge should be rendered with the primitives provided by func[{{x1,y1},{x2,y2},…},vw], where {{x1,y1},{x2,y2},…} are line segments and vw is the edge.
- In 3D, EdgeShapeFunction->func specifies that each vertex should be rendered with the primitives provided by func[{{x1,y1,z1},{x2,y2,z2},…},vw], where {{x1,y1,z1},{x2,y2,z2},…} are line segments and vw is the edge.
- The following named arguments can be used in the edge function func:
-
#Coordinates line segments {{x1,y1}, …} #Edge edge vw - Use ResourceData["EdgeShapeFunction"] to get a list of all named edge functions "nfunc":
- The wrapper Annotation[vw,EdgeShapeFunction->f] can be used when creating graphs in functions such as Graph etc.
Examples
open all close allBasic Examples (4)
Draw edges using a predefined edge function:
Graph[{12, 23, 31}, EdgeShapeFunction -> {{"HalfFilledArrow", "ArrowSize" -> .1}}]Specify an edge function for an individual edge:
Graph[{12, 23, 31}, EdgeShapeFunction -> {12 -> {"HalfFilledArrow", "ArrowSize" -> .1}}]Combine with a different default edge function:
Graph[{12, 23, 31}, EdgeShapeFunction -> {12 -> "HalfFilledArrow", "CarvedArrow"}]Use an Annotation wrapper to specify individual edge functions:
Graph[{Annotation[12, EdgeShapeFunction -> {"CarvedArrow", "ArrowSize" -> .1}], 23, 31}]Draw edges by running a program:
ef[pts_List, e_] :=
Block[{s = 0.015, g = [image]}, {Arrowheads[{{s, 0.33, g}, {s, 0.67, g}}], Arrow[pts]}]Graph[{12, 23, 31}, EdgeShapeFunction -> ef]Scope (10)
EdgeShapeFunction Specification (7)
EdgeShapeFunction can be used for general graphs:
{Graph[{12, 23, 31}, EdgeShapeFunction -> "CarvedArrow"], PathGraph[Range[25], EdgeShapeFunction -> "CarvedArrow"]}AdjacencyGraph[{{0, 1, 0}, {0, 0, 1}, {1, 0, 0}}, EdgeShapeFunction -> "CarvedArrow"]{PetersenGraph[5, 2, EdgeShapeFunction -> "CarvedArrow"], GridGraph[{3, 3}, EdgeShapeFunction -> "CarvedArrow"]}RandomGraph[UniformGraphDistribution[10, 20], EdgeShapeFunction -> "CarvedArrow"]Use EdgeShapeFunction in an Annotation wrapper:
Graph[{Annotation[12, EdgeShapeFunction -> "CarvedArrow"], 23, 31}]HighlightGraph[GridGraph[{2, 3}], Annotation[13, EdgeShapeFunction -> "CarvedArrow"]]EdgeShapeFunction works with patterns:
CompleteGraph[5, EdgeShapeFunction -> {_2 -> "CarvedArrow"}]EdgeShapeFunction can be combined with EdgeStyle:
Graph[{12, 23, 31}, EdgeStyle -> Blue, EdgeShapeFunction -> (Line[#1]&)]EdgeShapeFunction has higher priority than EdgeStyle:
Graph[{12, 23, 31}, EdgeStyle -> Blue, EdgeShapeFunction -> ({Red, Line[#1]}&)]EdgeShapeFunction Gallery (3)
Get a list of built-in settings for EdgeShapeFunction:
ResourceData["EdgeShapeFunction"]Undirected edges including the basic line:
Graph[{12, 23, 31}, EdgeShapeFunction -> "Line"]Lines with different glyphs on the edges:
Table[Graph[{12, 23, 31}, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, {"BoxLine", "DiamondLine", "DotLine"}}]Directed edges including solid arrows:
Table[Graph[{12, 23, 31}, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, ResourceData["EdgeShapeFunction", "FilledArrow"]}]Table[Graph[{12, 23, 31}, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, ResourceData["EdgeShapeFunction", "UnfilledArrow"]}]Table[Graph[{12, 23, 31}, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, ResourceData["EdgeShapeFunction", "CarvedArrow"]}]Possible Issues (1)
Using Rule to indicate edges does not work:
Graph[{1 -> 2, 2 -> 3, 3 -> 1}, EdgeShapeFunction -> {1 -> 2 -> "CarvedArrow"}]Use parentheses to get correct parsing:
1 -> 2 -> "CarvedArrow"//FullForm(1 -> 2) -> "CarvedArrow"//FullFormGraph[{1 -> 2, 2 -> 3, 3 -> 1}, EdgeShapeFunction -> {(1 -> 2) -> "CarvedArrow"}]Related Guides
Text
Wolfram Research (2010), EdgeShapeFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/EdgeShapeFunction.html (updated 2026).
CMS
Wolfram Language. 2010. "EdgeShapeFunction." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2026. https://reference.wolfram.com/language/ref/EdgeShapeFunction.html.
APA
Wolfram Language. (2010). EdgeShapeFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/EdgeShapeFunction.html
BibTeX
@misc{reference.wolfram_2026_edgeshapefunction, author="Wolfram Research", title="{EdgeShapeFunction}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/EdgeShapeFunction.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_edgeshapefunction, organization={Wolfram Research}, title={EdgeShapeFunction}, year={2026}, url={https://reference.wolfram.com/language/ref/EdgeShapeFunction.html}, note=[Accessed: 13-June-2026]}