VertexStyle
是 Graph 及相关函数的一个选项和注解,指定对顶点使用何种样式.
更多信息
- 可以使用如下选项设置:
-
Automatic 对样式使用自动设置 style 对所有顶点使用 style {v1->style1,v2->style2,…} 对顶点 vi 使用 stylei {patt1style1,patt2style2,…} 用 stylei 作为与模式 patti 匹配的顶点的样式 - 不具有显式顶点样式 v->style 的顶点采用默认样式.
- 封装 Style[v,style] 等价于 Annotation[v,VertexStyle->style],并且可在用诸如 Graph 的函数创建图时使用.
- VertexStyle 可以应用于点、线和面.
- 若要指定多个样式指令,使用 Directive[style1,style2,…].
- 样式和其它说明实际上以如下顺序应用:VertexStyle、Style 和其它封装以及 VertexShapeFunction,其中后面的说明覆盖前面的说明.
范例
打开所有单元 关闭所有单元基本范例 (2)
范围 (10)
VertexStyle 可用于一般图:
{Graph[{12, 23, 31}, VertexStyle -> Red, VertexSize -> Tiny], PathGraph[Range[20], VertexStyle -> Red, VertexSize -> 0.2]}AdjacencyGraph[{{0, 1, 1}, {1, 0, 1}, {1, 1, 0}}, VertexStyle -> Red, VertexSize -> Tiny]{PetersenGraph[5, 2, VertexStyle -> Red, VertexSize -> 0.2], GridGraph[{4, 4}, VertexStyle -> Red, VertexSize -> 0.2]}RandomGraph[UniformGraphDistribution[10, 20], VertexStyle -> Red, VertexSize -> 0.2]在 Annotation 封装中使用 VertexStyle:
Graph[{Annotation[1, VertexStyle -> Red], 2, 3}, {12, 23, 31}, VertexSize -> Tiny]或者,使用 Style 封装:
Graph[{Style[1, Red], 2, 3}, {12, 23, 31}, VertexSize -> Tiny]使用 Directive 来设置多个样式指令:
Table[CompleteGraph[5, VertexSize -> 0.2, VertexStyle -> s], {s, {Red, EdgeForm[None], Directive[Red, EdgeForm[None]]}}]VertexStyle 作用于模式:
CompleteGraph[5, VertexStyle -> {_ ? EvenQ -> Orange}, VertexSize -> 0.2]VertexStyle 可以与 VertexShapeFunction 合起来使用:
vf1[{xc_, yc_}, name_, {w_, h_}] := Rectangle[{xc - w, yc - h}, {xc + w, yc + h}]CompleteGraph[5, VertexSize -> 0.2, VertexStyle -> Blue, VertexShapeFunction -> vf1]VertexShapeFunction 具有比 VertexStyle 更高的优先级:
vf2[{xc_, yc_}, name_, {w_, h_}] := {Red, Rectangle[{xc - w, yc - h}, {xc + w, yc + h}]}CompleteGraph[5, VertexSize -> 0.2, VertexStyle -> Blue, VertexShapeFunction -> vf2]VertexStyle 可以与 BaseStyle 合起来使用:
CompleteGraph[5, VertexStyle -> LightBlue, BaseStyle -> EdgeForm[Dotted], VertexSize -> 0.2]VertexStyle 具有比 BaseStyle 更高的优先级:
CompleteGraph[5, VertexStyle -> LightBlue, BaseStyle -> Gray, VertexSize -> 0.2]VertexShape 不受 VertexStyle 影响:
CompleteGraph[5, VertexSize -> 0.2, VertexShape -> [image], VertexStyle -> Blue]文本
Wolfram Research (2010),VertexStyle,Wolfram 语言函数,https://reference.wolfram.com/language/ref/VertexStyle.html.
CMS
Wolfram 语言. 2010. "VertexStyle." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/VertexStyle.html.
APA
Wolfram 语言. (2010). VertexStyle. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/VertexStyle.html 年
BibTeX
@misc{reference.wolfram_2026_vertexstyle, author="Wolfram Research", title="{VertexStyle}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/VertexStyle.html}", note=[Accessed: 31-October-2026]}
BibLaTeX
@online{reference.wolfram_2026_vertexstyle, organization={Wolfram Research}, title={VertexStyle}, year={2010}, url={https://reference.wolfram.com/language/ref/VertexStyle.html}, note=[Accessed: 31-October-2026]}