是 Graph 和相关函数的一个选项和注释,它指定一个函数,用以生成绘制每条边所需的图形基元.
EdgeShapeFunction
是 Graph 和相关函数的一个选项和注释,它指定一个函数,用以生成绘制每条边所需的图形基元.
更多信息
- EdgeShapeFunction 也被称为边路由.
- EdgeShapeFunction 通常用于控制连接顶点的路径的视觉外观.
- 可以使用下列选项:
-
Automatic 默认的边函数 None 不绘制边 "nfunc" 一个已命名的边函数 func 一个普通边函数 {vivj->efij,…} 对于边 vivj 使用边函数 efij {pattiefi,…} 对于与模式 patti 匹配的边使用边函数 efi - EdgeShapeFunction->func 指定每个边应该使用由 func[{{x1,y1},{x2,y2},…},vw] 提供的图形基元绘制,其中 {{x1,y1},{x2,y2},…} 是线段,而 vw 是边.
- 在三维中,EdgeShapeFunction->func 指定每个顶点应使用由 func[{{x1,y1,z1},{x2,y2,z2},…},vw] 提供的图元进行渲染,其中 {{x1,y1,z1},{x2,y2,z2},…} 表示线段,而 vw 表示边.
- 以下命名参数可用于边函数 func:
-
#Coordinates 线段 {{x1,y1}, …} #Edge 边 vw - 使用 获取所有已命名边函数列表 "nfunc":
- 当我们在诸如 Graph 的函数中创建图时,可以使用封装 Annotation[vw,EdgeShapeFunction->f].
范例
打开所有单元 关闭所有单元基本范例 (4)
Graph[{12, 23, 31}, EdgeShapeFunction -> {{"HalfFilledArrow", "ArrowSize" -> .1}}]Graph[{12, 23, 31}, EdgeShapeFunction -> {12 -> {"HalfFilledArrow", "ArrowSize" -> .1}}]Graph[{12, 23, 31}, EdgeShapeFunction -> {12 -> "HalfFilledArrow", "CarvedArrow"}]使用一个 Annotation 封装来指定单个边函数:
Graph[{Annotation[12, EdgeShapeFunction -> {"CarvedArrow", "ArrowSize" -> .1}], 23, 31}]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]范围 (10)
EdgeShapeFunction 说明 (7)
EdgeShapeFunction 可用于普通图:
{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"]在 Annotation 封装中使用 EdgeShapeFunction:
Graph[{Annotation[12, EdgeShapeFunction -> "CarvedArrow"], 23, 31}]HighlightGraph[GridGraph[{2, 3}], Annotation[13, EdgeShapeFunction -> "CarvedArrow"]]EdgeShapeFunction 作用于模式:
CompleteGraph[5, EdgeShapeFunction -> {_2 -> "CarvedArrow"}]EdgeShapeFunction 可以与 EdgeStyle 合起来使用:
Graph[{12, 23, 31}, EdgeStyle -> Blue, EdgeShapeFunction -> (Line[#1]&)]EdgeShapeFunction 具有比 EdgeStyle 更高的优先级:
Graph[{12, 23, 31}, EdgeStyle -> Blue, EdgeShapeFunction -> ({Red, Line[#1]}&)]EdgeShapeFunction 样式设置功能 (3)
获取 EdgeShapeFunction 的内置设置列表:
ResourceData["EdgeShapeFunction"]Graph[{12, 23, 31}, EdgeShapeFunction -> "Line"]Table[Graph[{12, 23, 31}, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, {"BoxLine", "DiamondLine", "DotLine"}}]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"]}]可能存在的问题 (1)
用 Rule 表示边似乎不可行:
Graph[{1 -> 2, 2 -> 3, 3 -> 1}, EdgeShapeFunction -> {1 -> 2 -> "CarvedArrow"}]1 -> 2 -> "CarvedArrow"//FullForm(1 -> 2) -> "CarvedArrow"//FullFormGraph[{1 -> 2, 2 -> 3, 3 -> 1}, EdgeShapeFunction -> {(1 -> 2) -> "CarvedArrow"}]相关指南
-
▪
- 图的样式、标记和布局 ▪
- 图的属性 ▪
- 图注解 ▪
- 图的可视化
文本
Wolfram Research (2010),EdgeShapeFunction,Wolfram 语言函数,https://reference.wolfram.com/language/ref/EdgeShapeFunction.html (更新于 2026 年).
CMS
Wolfram 语言. 2010. "EdgeShapeFunction." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2026. https://reference.wolfram.com/language/ref/EdgeShapeFunction.html.
APA
Wolfram 语言. (2010). EdgeShapeFunction. Wolfram 语言与系统参考资料中心. 追溯自 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: 10-September-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: 10-September-2026]}