EdgeTaggedGraph[{e1,e2,…}]
给出一个图,用唯一的标签标注其中的边 ej.
EdgeTaggedGraph[{e1,e2,…}{t1,t2,…}]
给出一个图,用 tj 标注其中的边 ej.
EdgeTaggedGraph[{v1,v2,…},{e1,e2,…}{t1,t2,…}]
给出由顶点 vi 组成的图,用 tj 标注其中的边 ej.
EdgeTaggedGraph[{…,wi[vi],…},{…,wj[ej],…}{t1,t2,…}]
给出一个图,其中的顶点和边的注释由符号封装 wk 定义.
EdgeTaggedGraph
EdgeTaggedGraph[{e1,e2,…}]
给出一个图,用唯一的标签标注其中的边 ej.
EdgeTaggedGraph[{e1,e2,…}{t1,t2,…}]
给出一个图,用 tj 标注其中的边 ej.
EdgeTaggedGraph[{v1,v2,…},{e1,e2,…}{t1,t2,…}]
给出由顶点 vi 组成的图,用 tj 标注其中的边 ej.
EdgeTaggedGraph[{…,wi[vi],…},{…,wj[ej],…}{t1,t2,…}]
给出一个图,其中的顶点和边的注释由符号封装 wk 定义.
更多信息和选项
- EdgeTaggedGraph 生成一个 Graph 对象.
- EdgeTaggedGraph 通常用来构建一个图,自动生成边的标签和可区分的平行的边.
- EdgeTaggedGraph[{e1,e2,…}] 返回图,其中对所有的边进行标注,且平行的边都有唯一的标签. 平行的边 ej 的新标签是从 1 开始的整数. 保留边 ej 现有的不可复制的标签.
- EdgeTaggedGraph 支持与 Graph 一样的顶点、边、封装和选项.
所有选项的列表
范例
打开所有单元 关闭所有单元基本范例 (2)
范围 (27)
连通性 (8)
EdgeTaggedGraph[{12, 23, 31}]EdgeTaggedGraph[{12, 23, 31}]EdgeTaggedGraph[{1 -> 2, 2 -> 3, 3 -> 1}]EdgeTaggedGraph[{1 -> 2, 2 -> 3, 3 -> 1}, DirectedEdges -> False]EdgeTaggedGraph[{1, 2, 3, 4}, {12, 23, 31}]用 VertexList 和 EdgeList 获取顶点和边:
{g1, g2} = {EdgeTaggedGraph[{12, 23, 31}], EdgeTaggedGraph[{23, 12, 31}]}EdgeList /@ {g1, g2}VertexList /@ {g1, g2}用一个明确的顶点列表来控制 VertexList 使用的顺序:
{g1, g2} = {EdgeTaggedGraph[{1, 2, 3}, {23, 12, 31}], EdgeTaggedGraph[{3, 2, 1}, {23, 12, 31}]}VertexList /@ {g1, g2}{EdgeTaggedGraph[{12, 22}], EdgeTaggedGraph[{12, 22}]}{EdgeTaggedGraph[{ab, bc, ca}], EdgeTaggedGraph[{"foo""bar", "bar""gnu", "gnu""foo"}],
EdgeTaggedGraph[{[image][image], [image][image], [image][image]}]}VertexList /@ %封装 (5)
{EdgeTaggedGraph[{Style[1, Red], 2, 3}, {12, 23, 31}], EdgeTaggedGraph[{1, 2, 3}, {Style[12, Red], 23, 31}]}{EdgeTaggedGraph[{1, 2, Labeled[Style[3, Red], "hello"]}, {12, 23, 31}], EdgeTaggedGraph[{1, 2, 3}, {Style[Labeled[12, "hello"], Red], 23, 31}]}通过封装(如 Tooltip)添加交互功能:
EdgeTaggedGraph[{12, 23, Tooltip[Style[31, Red], "hello"]}]EdgeTaggedGraph[{12, 23, Tooltip[Style[31, Red], Plot[Sin[x], {x, 0, 2Pi}]]}]用 Button 在点击边或顶点时激活操作:
{EdgeTaggedGraph[{12, 23, Button[Style[31, Red], Speak["Edge from 3 to 1"]]}], Graph[{1, 2, Button[Style[3, Red], Speak["Vertex 3"]]}, {12, 23, 31}, VertexSize -> Medium]}用 PopupWindow 提供更详细的信息:
EdgeTaggedGraph[{12, 23, PopupWindow[Style[31, Red], DateListPlot[FinancialData["IBM", "Jan. 1, 2004"]]]}]样式 (8)
{EdgeTaggedGraph[{12, 23, 31}, VertexStyle -> Green], EdgeTaggedGraph[{12, 23, 31}, EdgeStyle -> Green]}{EdgeTaggedGraph[{12, 23, 31}, VertexStyle -> {1 -> Green, Orange}], EdgeTaggedGraph[{12, 23, 31}, EdgeStyle -> {12 -> Green, Orange}]}{EdgeTaggedGraph[{Style[1, Green], 2, 3}, {12, 23, 31}, VertexStyle -> Orange], EdgeTaggedGraph[{Style[12, Green], 23, 31}, EdgeStyle -> Orange]}Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> s, PlotLabel -> s], {s, {Tiny, Small, Medium, Large}}]Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> s, PlotLabel -> s], {s, {0.1, 0.2, 0.5, 1}}]使用 VertexShapeFunction 的内置设置集合:
Table[EdgeTaggedGraph[{12, 23, 31}, VertexShapeFunction -> s, VertexSize -> 0.2, PlotLabel -> s], {s, {"Triangle", "Square", "Rectangle", "Pentagon", "Hexagon", "Octagon"}}]Table[EdgeTaggedGraph[{12, 23, 31}, VertexShapeFunction -> s, VertexSize -> 0.2, PlotLabel -> Style[s, 9]], {s, ResourceData["VertexShapeFunction", "Rounded"]}]Table[EdgeTaggedGraph[{12, 23, 31}, VertexShapeFunction -> s, VertexSize -> 0.2, PlotLabel -> s], {s, ResourceData["VertexShapeFunction", "Concave"]}]EdgeTaggedGraph[{12, 23, 31}, VertexShapeFunction -> { 1 -> "Square"}, VertexSize -> 0.2]EdgeTaggedGraph[{12, 23, 31}, VertexShapeFunction -> { 1 -> "Square", "Triangle"}, VertexSize -> 0.2]将任意 Graphics、Image 或者 Graphics3D 作为顶点形状使用:
Table[EdgeTaggedGraph[{12, 23, 31}, VertexShape -> s, VertexSize -> Medium], {s, {[image], [image], [image]}}]使用 EdgeShapeFunction 的内置设置集合:
Table[EdgeTaggedGraph[{12, 23, 31}, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, {"BoxLine", "DiamondLine", "DotLine"}}]Table[EdgeTaggedGraph[{12, 23, 31}, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> Style[ef, 9]], {ef, ResourceData["EdgeShapeFunction", "FilledArrow"]}]Table[EdgeTaggedGraph[{12, 23, 31}, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> Style[ef, 9]], {ef, ResourceData["EdgeShapeFunction", "UnfilledArrow"]}]Table[EdgeTaggedGraph[{12, 23, 31}, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> Style[ef, 9]], {ef, ResourceData["EdgeShapeFunction", "CarvedArrow"]}]EdgeTaggedGraph[{12, 23, 31}, EdgeShapeFunction -> {12 -> "FilledArrow"}]EdgeTaggedGraph[{12, 23, 31}, EdgeShapeFunction -> {12 -> "FilledArrow", "CarvedArrow"}]添加标签 (6)
{EdgeTaggedGraph[{12, 23, Labeled[31, "hello"]}], EdgeTaggedGraph[{1, 2, Labeled[3, "hello"]}, {12, 23, 31}]}Table[EdgeTaggedGraph[{1, 2, Labeled[3, l]}, {12, 23, 31}, ImagePadding -> 25], {l, {Sin[x], [image], [image]}}]Table[EdgeTaggedGraph[{12, 23, Labeled[31, l]}], {l, {Sin[x], [image], [image]}}]利用 Placed 控制顶点标签的位置,包括用符号表示的顶点内的位置:
Table[EdgeTaggedGraph[{1, 2, Labeled[3, Placed["■■", p]]}, {12, 23, 31}, PlotLabel -> p, VertexSize -> Large, VertexShapeFunction -> "Square"], {p, {Left, Right, Bottom, Top}}]Table[EdgeTaggedGraph[{1, 2, Labeled[3, Placed["■■", p]]}, {12, 23, 31}, PlotLabel -> p, VertexShapeFunction -> "Square", VertexSize -> Small], {p, {Before, After, Below, Above}}]Table[EdgeTaggedGraph[{1, 2, Labeled[3, Placed["■", p]]}, {12, 23, 31}, VertexSize -> 0.25, VertexShapeFunction -> "Square", PlotLabel -> p, BaselinePosition -> Axis], {p, {{0, 0}, {1 / 2, 1 / 2}, {1, 1}}}]在封装中使用 Placed 放置多个标签:
EdgeTaggedGraph[{1, 2, Labeled[3, Placed[{"lbl1", "lbl2"}, {Above, Below}]]}, {12, 23, 31}]EdgeTaggedGraph[{1, 2, Labeled[3, Placed[{"lbl1", "lbl2", "lbl3", "lbl4"}, {Above, After, Below, Before}]]}, {12, 23, 31}]用 VertexLabels 放置多个标签:
EdgeTaggedGraph[{12, 23, 31}, VertexLabels -> {3 -> Placed[{"lbl1", "lbl2"}, {Above, Below}]}]将 Placed 与符号式位置合用,控制标签在边上的位置:
Table[EdgeTaggedGraph[{Labeled[12, Placed["■■", p]], 23, 31}, PlotLabel -> p, VertexSize -> Small], {p, {"Start", "Middle", "End"}}]Table[EdgeTaggedGraph[{Labeled[12, Placed["■■", p]], 23, 31}, PlotLabel -> p, VertexSize -> Small, BaselinePosition -> Axis], {p, {0, 1 / 4, 1 / 3}}]在封装中使用 Placed 放置多个标签:
EdgeTaggedGraph[{12, 23, Labeled[31, Placed[{"lbl1", "lbl2"}, {"Start", "End"}]]}]EdgeTaggedGraph[{12, 23, Labeled[31, Placed[{"lbl1", "lbl2", "lbl3"}, {"Start", "Middle", "End"}]]}]用 EdgeLabels 放置多个标签:
EdgeTaggedGraph[{12, 23, 31}, EdgeLabels -> {31 -> Placed[{"lbl1", "lbl2"}, {"Start", "End"}]}]选项 (86)
AnnotationRules (3)
EdgeTaggedGraph[{1, 2, 3}, {12, 23, 31}, AnnotationRules -> {1 -> {VertexLabels -> "hello"}}]EdgeTaggedGraph[{12, 23, 31}, AnnotationRules -> {12 -> {EdgeLabels -> "hello"}}]EdgeTaggedGraph[{1, 2, 3}, {12, 23, 31}, AnnotationRules -> {"GraphProperties" -> {"Message" -> "hello"}}]AnnotationValue[%, "Message"]DirectedEdges (2)
EdgeTaggedGraph[{1 -> 2, 2 -> 3, 3 -> 1}]用 DirectedEdges->False 将规则解释为无向边:
EdgeTaggedGraph[{1 -> 2, 2 -> 3, 3 -> 1}, DirectedEdges -> False]用 DirectedEdge 或 UndirectedEdge 直接指定是有向图还是无向图:
{EdgeTaggedGraph[{12, 23, 31}], EdgeTaggedGraph[{12, 23, 31}]}EdgeLabels (7)
EdgeTaggedGraph[{12, 23, 31}, EdgeLabels -> {12 -> "Hello"}]el = {12, 23, 31};EdgeTaggedGraph[el, EdgeLabels -> Table[el[[i]] -> Subscript[e, i], {i, Length[el]}]]EdgeTaggedGraph[{12, 23, 31}, EdgeLabels -> {12 -> [image], 23 -> [image], 31 -> [image]}]将 Placed 与符号位置一起使用,以控制在边的什么位置放置标签:
Table[EdgeTaggedGraph[{12, 23, 31}, EdgeLabels -> {12 -> Placed["■■■", p]}, PlotLabel -> p], {p, {"Start", "Middle", "End"}}]Table[EdgeTaggedGraph[{12, 23, 31}, EdgeLabels -> {12 -> Placed["■■■", p]}, PlotLabel -> p, BaselinePosition -> Axis], {p, {0, 1 / 3, 1 / 4}}]Table[EdgeTaggedGraph[{12, 23, 31}, EdgeLabels -> {31 -> Placed["■■■", {1 / 2, p}]}, PlotLabel -> p, BaselinePosition -> Axis], {p, {{0, 0}, {1 / 2, 1 / 2}, {1, 1}}}]用封装中的 Placed 放置多个标签:
EdgeTaggedGraph[{12, 23, Labeled[31, Placed[{"lbl1", "lbl2"}, {"Start", "End"}]]}]EdgeTaggedGraph[{12, 23, Labeled[31, Placed[{"lbl1", "lbl2", "lbl3"}, {"Start", "Middle", "End"}]]}]用 EdgeLabels 放置多个标签:
EdgeTaggedGraph[{12, 23, 31}, EdgeLabels -> {31 -> Placed[{"lbl1", "lbl2"}, {"Start", "End"}]}]通过 Tooltip 和 StatusArea 用值进行自动标注:
EdgeTaggedGraph[{12, 23, 31}, EdgeLabels -> Placed["Name", Tooltip]]EdgeTaggedGraph[{12, 23, 31}, EdgeLabels -> Placed["Name", StatusArea]]EdgeShapeFunction (6)
获取 EdgeShapeFunction 的内置设置列表:
ResourceData["EdgeShapeFunction"]EdgeTaggedGraph[{12, 23, 31}, EdgeShapeFunction -> "Line"]Table[EdgeTaggedGraph[{12, 23, 31}, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, {"BoxLine", "DiamondLine", "DotLine"}}]Table[EdgeTaggedGraph[{12, 23, 31}, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> Style[ef, 10]], {ef, ResourceData["EdgeShapeFunction", "FilledArrow"]}]Table[EdgeTaggedGraph[{12, 23, 31}, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> Style[ef, 9]], {ef, ResourceData["EdgeShapeFunction", "UnfilledArrow"]}]Table[EdgeTaggedGraph[{12, 23, 31}, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> Style[ef, 10]], {ef, ResourceData["EdgeShapeFunction", "CarvedArrow"]}]EdgeTaggedGraph[{12, 23, 31}, EdgeShapeFunction -> {12 -> "FilledArrow"}]EdgeTaggedGraph[{12, 23, 31}, EdgeShapeFunction -> {12 -> "FilledArrow", "CarvedArrow"}]ef[pts_List, e_] :=
Block[{s = 0.015, g = [image]}, {Arrowheads[{{s, 0.33, g}, {s, 0.67, g}}], Arrow[pts]}]EdgeTaggedGraph[{12, 23, 31}, EdgeShapeFunction -> ef]EdgeShapeFunction 可与 EdgeStyle 组合使用:
EdgeTaggedGraph[{12, 23, 31}, EdgeStyle -> Blue, EdgeShapeFunction -> (Line[#1]&)]EdgeShapeFunction 比 EdgeStyle 的优先级高:
EdgeTaggedGraph[{12, 23, 31}, EdgeStyle -> Blue, EdgeShapeFunction -> ({Red, Line[#1]}&)]EdgeStyle (4)
Table[EdgeTaggedGraph[{12, 23, 31}, EdgeStyle -> style], {style, {Gray, Dashed, Thick}}]EdgeTaggedGraph[{12, 23, 31}, EdgeStyle -> {12 -> Blue, 23 -> Dashed}]EdgeStyle 可与 EdgeShapeFunction 组合使用:
ef1[el_, ___] := Arrow[el, 0.1]EdgeTaggedGraph[{12, 23, 31}, EdgeStyle -> Blue, EdgeShapeFunction -> ef1]EdgeShapeFunction 比 EdgeStyle 的优先级高:
ef2[el_, ___] := {Red, Arrow[el, 0.1]}EdgeTaggedGraph[{12, 23, 31}, EdgeStyle -> Blue, EdgeShapeFunction -> ef2]EdgeTaggedGraph[{12, 23, 31}, BaseStyle -> Red, EdgeStyle -> Dashed]EdgeTaggedGraph[{12, 23, 31}, BaseStyle -> Red, EdgeStyle -> Blue]EdgeWeight (2)
EdgeTaggedGraph[{12, 23, 31}, EdgeWeight -> RandomInteger[5, 3]]WeightedAdjacencyMatrix[%]//MatrixFormEdgeTaggedGraph[{12, 23, 31}, EdgeWeight -> {a, b, c}]WeightedAdjacencyMatrix[%]//MatrixFormGraphHighlight (3)
EdgeTaggedGraph[{12, 23, 31}, VertexSize -> Tiny, GraphHighlight -> {1}]EdgeTaggedGraph[{12, 23, 31}, VertexSize -> Tiny, GraphHighlight -> {23}]EdgeTaggedGraph[{12, 23, 31}, VertexSize -> Tiny, GraphHighlight -> {1, 2, 31, 23}]GraphHighlightStyle (2)
获取 GraphHighlightStyle 的内置设置的列表:
ResourceData["GraphHighlightStyle"]使用 GraphHighlightStyle 的内置设置:
EdgeTaggedGraph[{12, 23, 31}, GraphHighlight -> {1, 23}, VertexSize -> Small, GraphHighlightStyle -> #, PlotLabel -> #]& /@ Select[ResourceData["GraphHighlightStyle"], # =!= Automatic&]GraphLayout (5)
EdgeTaggedGraph[{12, 23, 31}, GraphLayout -> Automatic]Table[EdgeTaggedGraph[Table[ii + 1, {i, 20}], GraphLayout -> l, PlotLabel -> l], {l, {"CircularEmbedding", "SpiralEmbedding"}}]el = EdgeList@GridGraph[{10, 10}];Table[
EdgeTaggedGraph[el, GraphLayout -> l, PlotLabel -> Style[l, 10]], {l, {"SpringEmbedding", "SpringElectricalEmbedding", "HighDimensionalEmbedding"}}]VertexCoordinates 将覆盖 GraphLayout 的坐标:
{EdgeTaggedGraph[{12, 23, 31}, GraphLayout -> "SpringElectricalEmbedding"],
EdgeTaggedGraph[{12, 23, 31}, GraphLayout -> "SpringElectricalEmbedding", VertexCoordinates -> Table[{i, i}, {i, 0, 2}]]}用 AbsoluteOptions 提取用布局算法得出的 VertexCoordinates:
EdgeTaggedGraph[{12, 23, 31}]AbsoluteOptions[%, VertexCoordinates]PlotTheme (4)
基本主题 (2)
VertexCoordinates (3)
EdgeTaggedGraph[{12, 23, 31}]用 AbsoluteOptions 提取所得的顶点坐标:
AbsoluteOptions[%, VertexCoordinates]ellipseLayout[n_, {a_, b_}] := Table[{a Cos[2Pi / n u], b Sin[2Pi / n u]}, {u, 1, n}]Graphics[Point[ellipseLayout[20, {2, 1}]]]EdgeTaggedGraph[Table[iMod[i + 1, 20, 1], {i, 20}], VertexCoordinates -> ellipseLayout[20, {2, 1}]]VertexCoordinates 比 GraphLayout 的优先级高:
EdgeTaggedGraph[{12, 23, 31}, VertexCoordinates -> Table[{i, i}, {i, 3}], GraphLayout -> "CircularEmbedding"]VertexLabels (13)
EdgeTaggedGraph[{12, 23, 31}, VertexLabels -> "Name"]EdgeTaggedGraph[{12, 23, 31}, VertexLabels -> {2 -> "one"}]EdgeTaggedGraph[{12, 23, 31}, VertexLabels -> Table[i -> Subscript[v, i], {i, 3}]]EdgeTaggedGraph[{12, 23, 31}, VertexLabels -> {1 -> [image], 2 -> [image], 3 -> [image]}, ImagePadding -> 30]将 Placed 与符号式位置合用,控制标签的放置,包括顶点外的位置:
Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> 0.1, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed["■", p], {i, 3}], PlotLabel -> p], {p, {Before, After, Below, Above}}]pl = {{Before, Below}, {After, Below}, {Before, Above}, {After, Above}};Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> 0.1, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed["■", p], {i, 3}], PlotLabel -> p], {p, pl}]Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> 0.25, VertexLabels -> Table[i -> Placed[[image], p], {i, 3}], VertexShapeFunction -> "Square", PlotLabel -> p], {p, {Left, Top, Right, Bottom}}]pl = {{Left, Bottom}, {Right, Bottom}, {Left, Top}, {Right, Top}};Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> 0.25, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed[[image], p], {i, 3}], PlotLabel -> p], {p, pl}]Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> 0.25, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed[[image], p], {i, 3}], PlotLabel -> p, BaselinePosition -> Axis], {p, {{0, 0}, {1 / 2, 1 / 2}, {1, 1}}}]Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> 0.35, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed[[image], {{1, 1}, p}], {i, 3}], PlotLabel -> p, BaselinePosition -> Axis], {p, {{0, 0}, {1 / 2, 1 / 2}, {1, 1}}}]在封装中使用 Placed 放置多个标签:
EdgeTaggedGraph[{1, 2, Labeled[3, Placed[{"lbl1", "lbl2"}, {Above, Below}]]}, {12, 23, 31}]EdgeTaggedGraph[{1, 2, Labeled[3, Placed[{"lbl1", "lbl2", "lbl3", "lbl4"}, {Above, After, Below, Before}]]}, {12, 23, 31}]用 VertexLabels 放置多个标签:
EdgeTaggedGraph[{12, 23, 31}, VertexLabels -> {3 -> Placed[{"lbl1", "lbl2"}, {Above, Below}]}]EdgeTaggedGraph[{12, 23, 31}, VertexLabels -> Placed["Name", Tooltip]]或 StatusArea:
EdgeTaggedGraph[{12, 23, 31}, VertexLabels -> Placed["Name", StatusArea]]rotateLabel[lbl_] := Rotate[lbl, 45Degree]EdgeTaggedGraph[{12, 23, 31}, VertexLabels -> Table[i -> Placed["xxx", Below, rotateLabel], {i, 3}]]panelLabel[lbl_] := Panel[lbl, FrameMargins -> 0, Background -> Lighter[Yellow, 0.7]]EdgeTaggedGraph[{12, 23, 31}, VertexLabels -> Table[i -> Placed["xxx", Center, panelLabel], {i, 3}]]hyperlinkLabel[lbl_] := Hyperlink[lbl, "http://www.wolfram.com"]EdgeTaggedGraph[{12, 23, 31}, VertexLabels -> Table[i -> Placed["xxx", Center, hyperlinkLabel], {i, 3}]]VertexShape (5)
使用任意 Graphics、Image 或 Graphics3D 作为顶点的形状:
Table[EdgeTaggedGraph[{12, 23, 31}, VertexShape -> s, VertexSize -> Medium], {s, {[image], [image], [image]}}]EdgeTaggedGraph[{12, 23, 31}, VertexShape -> {2 -> [image]}, VertexSize -> Medium]VertexShape 可与 VertexSize 组合使用:
Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> s, VertexShape -> [image], PlotLabel -> s], {s, {Small, Large}}]VertexShape 不受 VertexStyle 的影响:
EdgeTaggedGraph[{12, 23, 31}, VertexSize -> 0.2, VertexShape -> [image], VertexStyle -> Blue]VertexShapeFunction 比 VertexShape 的优先级高:
EdgeTaggedGraph[{12, 23, 31}, VertexSize -> 0.1, VertexShapeFunction -> "Square", VertexShape -> [image]]VertexShapeFunction (11)
获取 VertexShapeFunction 的内置集合列表:
ResourceData["VertexShapeFunction"]使用 "Basic" 集合中 VertexShapeFunction 的内置设置:
ResourceData["VertexShapeFunction", "Basic"]Table[EdgeTaggedGraph[{12, 23, 31}, VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, {"Triangle", "Square", "Rectangle", "Pentagon", "Hexagon", "Octagon"}}]Table[EdgeTaggedGraph[{12, 23, 31}, VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, {"DownTrapezoid", "UpTrapezoid", "Parallelogram", "FiveDown", "Circle", "Diamond", "Star", "Capsule"}}]使用 "Rounded" 集合中 VertexShapeFunction 的内置设置:
ResourceData["VertexShapeFunction", "Rounded"]Table[EdgeTaggedGraph[{12, 23, 31}, VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> Style[vf, 9]], {vf, ResourceData["VertexShapeFunction", "Rounded"]}]使用 "Concave" 集合中 VertexShapeFunction 的内置设置:
ResourceData["VertexShapeFunction", "Concave"]Table[EdgeTaggedGraph[{12, 23, 31}, VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, ResourceData["VertexShapeFunction", "Concave"]}]EdgeTaggedGraph[{12, 23, 31}, VertexShapeFunction -> { 1 -> "Square"}, VertexSize -> 0.2]EdgeTaggedGraph[{12, 23, 31}, VertexShapeFunction -> { 1 -> "Square", "Triangle"}, VertexSize -> 0.2]EdgeTaggedGraph[{12, 23, 31}, VertexShapeFunction -> (Inset[[image], #]&)]vf[{xc_, yc_}, name_, {w_, h_}] :=
Block[{xmin = xc - w, xmax = xc + w, ymin = yc - h, ymax = yc + h},
Polygon[{{xmin, ymin}, {xmax, ymax}, {xmin, ymax}, {xmax, ymin}}]
];EdgeTaggedGraph[{12, 23, 31}, VertexShapeFunction -> vf, VertexSize -> 0.2]VertexShapeFunction 可与 VertexStyle 组合使用:
vf1[{xc_, yc_}, name_, {w_, h_}] := Rectangle[{xc - w, yc - h}, {xc + w, yc + h}]EdgeTaggedGraph[{12, 23, 31}, 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}]}EdgeTaggedGraph[{12, 23, 31}, VertexSize -> 0.2, VertexStyle -> Blue, VertexShapeFunction -> vf2]VertexShapeFunction 可与 VertexSize 组合使用:
EdgeTaggedGraph[{12, 23, 31}, VertexShapeFunction -> "Star", VertexSize -> {1 -> Small, Medium}]VertexShapeFunction 比 VertexShape 的优先级高:
EdgeTaggedGraph[{12, 23, 31}, VertexSize -> 0.3, VertexShapeFunction -> "Star", VertexShape -> [image]]VertexSize (8)
EdgeTaggedGraph[{12, 23, 31}, VertexSize -> Automatic]Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> s, PlotLabel -> s], {s, {Tiny, Small, Medium, Large}}]Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> s, PlotLabel -> s], {s, 0.1, 1, 0.3}]Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> {"Scaled", s}, PlotLabel -> {"Scaled", s}], {s, 0.1, 1, 0.3}]Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> s, PlotLabel -> s], {s, {{0.1, 0.2}, {0.2, 0.1}}}]EdgeTaggedGraph[{12, 23, 31}, VertexSize -> {1 -> 0.2, 2 -> 0.3}]VertexSize 可与 VertexShapeFunction 组合使用:
Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> s, VertexShapeFunction -> "Square", PlotLabel -> s], {s, {0.05, 0.1, 0.2}}]VertexSize 可与 VertexShape 组合使用:
Table[EdgeTaggedGraph[{12, 23, 31}, VertexSize -> s, VertexShape -> [image], PlotLabel -> s], {s, {0.1, 0.2, 0.4}}]VertexStyle (5)
Table[EdgeTaggedGraph[{12, 23, 31}, VertexStyle -> style, VertexSize -> 0.2], {style, {Yellow, EdgeForm[Dashed]}}]EdgeTaggedGraph[{12, 23, 31}, VertexStyle -> {1 -> Blue, 2 -> Red}, VertexSize -> 0.2]VertexShapeFunction 可与 VertexStyle 组合使用:
vf1[{xc_, yc_}, name_, {w_, h_}] := Rectangle[{xc - w, yc - h}, {xc + w, yc + h}]EdgeTaggedGraph[{12, 23, 31}, 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}]}EdgeTaggedGraph[{12, 23, 31}, VertexSize -> 0.2, VertexStyle -> Blue, VertexShapeFunction -> vf2]VertexStyle 可与 BaseStyle 组合使用:
EdgeTaggedGraph[{12, 23, 31}, VertexStyle -> LightBlue, BaseStyle -> EdgeForm[Dotted], VertexSize -> 0.2]VertexStyle 比 BaseStyle 的优先级高:
EdgeTaggedGraph[{12, 23, 31}, VertexStyle -> LightBlue, BaseStyle -> Gray, VertexSize -> 0.2]VertexShape 不受 VertexStyle 的影响:
EdgeTaggedGraph[{12, 23, 31}, VertexSize -> 0.2, VertexShape -> [image], VertexStyle -> Blue]VertexWeight (3)
EdgeTaggedGraph[{12, 23, 31}, VertexWeight -> {2, 3, 4}]AnnotationValue[{%, 1}, VertexWeight]EdgeTaggedGraph[{12, 23, 31}, VertexWeight -> {1 -> 2}]AnnotationValue[{%, 1}, VertexWeight]EdgeTaggedGraph[{12, 23, 31}, VertexWeight -> {a, b, c}]AnnotationValue[{%, 1}, VertexWeight]应用 (4)
基本应用 (1)
图的注释 (3)
EdgeTaggedGraph[{12, 12, 12}, EdgeLabels -> "Index"]EdgeTaggedGraph[{12, 13, 12, 32, 12}, EdgeStyle -> (_ :> RandomColor[])]g = EdgeTaggedGraph[{Annotation[12, "name" -> "A"], Annotation[12, "name" -> "B"], Annotation[12, "name" -> "C"]}]AnnotationValue[{g, {1Overscript[, 1]2, 1Overscript[, 2]2, 1Overscript[, 3]2}}, "name"]属性和关系 (7)
用 VertexCount 和 EdgeCount 计算顶点数和边数:
g = EdgeTaggedGraph[Table[iMod[i + 1, 2], {i, 20}]]{VertexCount[g], EdgeCount[g]}用 VertexList 和 EdgeList 以标准顺序列出顶点和边:
g = EdgeTaggedGraph[{12, 23, 31}];{VertexList[g], EdgeList[g]}g1 = EdgeTaggedGraph[{23, 31, 12}];{VertexList[g1], EdgeList[g1]}g2 = EdgeTaggedGraph[{31, 23, 12}];{VertexList[g2], EdgeList[g2]}从一个图计算 AdjacencyMatrix:
g = EdgeTaggedGraph[{ab, bc, ca}];(m = AdjacencyMatrix[g]//Normal)//MatrixFormEdgeTaggedGraph[{12, 23, 31}];EdgeTaggedGraphQ[%]用 EdgeTags 获取边的标注:
EdgeTaggedGraph[{12, 23, 31}]EdgeTags[%]可用 IndexEdgeTaggedGraph 获取有标注的图:
IndexEdgeTaggedGraph[{12, 23, 31}]EdgeTaggedGraphQ[%]用 DirectedEdge 或 UndirectedEdge 直接指定边是有向边还是无向边:
{EdgeTaggedGraph[{12, 23, 31}], EdgeTaggedGraph[{12, 23, 31}]}可能存在的问题 (1)
无法区分 Graph 中平行的边:
Graph[{Style[12, Red], Style[12, Blue], 23, 31}]用 EdgeTaggedGraph 为每条边分配一个唯一的标签:
EdgeTaggedGraph[{Style[12, Red], Style[12, Blue], 23, 31}]EdgeList[%]相关指南
-
▪
- 图的操作与修改
文本
Wolfram Research (2020),EdgeTaggedGraph,Wolfram 语言函数,https://reference.wolfram.com/language/ref/EdgeTaggedGraph.html.
CMS
Wolfram 语言. 2020. "EdgeTaggedGraph." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/EdgeTaggedGraph.html.
APA
Wolfram 语言. (2020). EdgeTaggedGraph. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/EdgeTaggedGraph.html 年
BibTeX
@misc{reference.wolfram_2026_edgetaggedgraph, author="Wolfram Research", title="{EdgeTaggedGraph}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/EdgeTaggedGraph.html}", note=[Accessed: 07-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_edgetaggedgraph, organization={Wolfram Research}, title={EdgeTaggedGraph}, year={2020}, url={https://reference.wolfram.com/language/ref/EdgeTaggedGraph.html}, note=[Accessed: 07-September-2026]}