DeBruijnGraph[m,n]
给出具有 m 个符号的 n 维 De Bruijn 图.
DeBruijnGraph[m,n,type]
给出连通度由 type 确定的 De Bruijn 图.
DeBruijnGraph
DeBruijnGraph[m,n]
给出具有 m 个符号的 n 维 De Bruijn 图.
DeBruijnGraph[m,n,type]
给出连通度由 type 确定的 De Bruijn 图.
更多信息和选项
- DeBruijnGraph[m,n] 有 mn 个顶点,包含 m 个符号组成的所有长度为 n 的序列. 给定两个顶点v={s1,…,sn} 和
={t1,…,tn},从 v 到
之间存在一条边,并且满足 s2==t1、s3==t2、…、sn==tn-1. - DeBruijnGraph[m,n,type] 指定不同的连通度类型. 可以给出以下类型:
-
"Noncyclic"
, …, 
"LeftShift"
, s2t1, …, sn 
"RightShift"
, …,
, 
- DeBruijnGraph[…] 是一个有向图.
- DeBruijnGraph 采用和 Graph 相同的选项.
所有选项的列表
范例
打开所有单元 关闭所有单元基本范例 (3)
{DeBruijnGraph[2, 2], DeBruijnGraph[2, 3]}{DeBruijnGraph[2, 2], DeBruijnGraph[3, 2]}Table[DeBruijnGraph[2, 3, type, PlotLabel -> type, BaselinePosition -> Top], {type, {"Noncyclic", "LeftShift", "RightShift" }}]选项 (79)
AnnotationRules (2)
EdgeLabels (7)
DeBruijnGraph[2, 2, EdgeLabels -> {12 -> "Hello"}]el = EdgeList[DeBruijnGraph[2, 2]]DeBruijnGraph[2, 2, EdgeLabels -> Table[el[[i]] -> Subscript["e", i], {i, Length[el]}]]DeBruijnGraph[2, 2, EdgeLabels -> {12 -> [image], 23 -> [image], 31 -> [image]}]使用带有符号位置信息的 Placed 来控制沿着一条边的标签位置:
Table[DeBruijnGraph[2, 2, EdgeLabels -> {23 -> Placed["■■■", p]}, PlotLabel -> p], {p, {"Start", "Middle", "End"}}]Table[DeBruijnGraph[2, 2, EdgeLabels -> {23 -> Placed["■■■", p]}, PlotLabel -> p, BaselinePosition -> Bottom], {p, {0, 1 / 4, 1 / 3}}]Table[DeBruijnGraph[2, 2, EdgeLabels -> {23 -> Placed["■■■", {1 / 2, p}]}, PlotLabel -> p, BaselinePosition -> Bottom], {p, {{0, 0}, {1 / 2, 1 / 2}, {1, 1}}}]DeBruijnGraph[2, 2, EdgeLabels -> {31 -> Placed[{"lbl1", "lbl2"}, {"Start", "End"}]}]DeBruijnGraph[2, 2, EdgeLabels -> {31 -> Placed[{"lbl1", "lbl2", "lbl3"}, {"Start", "Middle", "End"}]}]通过 Tooltip 和 StatusArea 的值,使用自动标签:
DeBruijnGraph[2, 2, EdgeLabels -> Placed["Name", Tooltip]]DeBruijnGraph[2, 2, EdgeLabels -> Placed["Name", StatusArea]]EdgeShapeFunction (6)
获取 EdgeShapeFunction 的内置设置列表:
ResourceData["EdgeShapeFunction"]DeBruijnGraph[2, 2, EdgeShapeFunction -> "Line"]Table[DeBruijnGraph[2, 2, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, {"BoxLine", "DiamondLine", "DotLine"}}]Table[DeBruijnGraph[2, 2, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, ResourceData["EdgeShapeFunction", "FilledArrow"]}]Table[DeBruijnGraph[2, 2, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, ResourceData["EdgeShapeFunction", "UnfilledArrow"]}]Table[DeBruijnGraph[2, 2, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, ResourceData["EdgeShapeFunction", "CarvedArrow"]}]DeBruijnGraph[2, 2, EdgeShapeFunction -> {12 -> "CarvedArrow"}]DeBruijnGraph[2, 2, EdgeShapeFunction -> {12 -> "FilledArcArrow", "CarvedArrow"}]ef[pts_List, e_] :=
Block[{s = 0.015, g = [image]}, {Arrowheads[{{s, 0.33, g}, {s, 0.67, g}}], Arrow[pts]}]DeBruijnGraph[2, 2, EdgeShapeFunction -> ef]EdgeShapeFunction 可以与 EdgeStyle 合起来使用:
DeBruijnGraph[2, 2, EdgeStyle -> Blue, EdgeShapeFunction -> (Line[#1]&)]EdgeShapeFunction 具有比 EdgeStyle 更高的优先级:
DeBruijnGraph[2, 2, EdgeStyle -> Blue, EdgeShapeFunction -> ({Red, Line[#1]}&)]EdgeStyle (2)
EdgeWeight (2)
DeBruijnGraph[2, 2, EdgeWeight -> RandomInteger[5, 8]]WeightedAdjacencyMatrix[%]//MatrixFormDeBruijnGraph[2, 2, EdgeWeight -> {a, b, c, d, e, f, g, h}]WeightedAdjacencyMatrix[%]//MatrixFormGraphHighlight (3)
DeBruijnGraph[2, 2, VertexSize -> Tiny, GraphHighlight -> {1}]DeBruijnGraph[2, 2, VertexSize -> Tiny, GraphHighlight -> {23}]DeBruijnGraph[2, 2, VertexSize -> Tiny, GraphHighlight -> {1, 2, 23, 24}]GraphHighlightStyle (2)
获取 GraphHighlightStyle 的内置设置列表:
ResourceData["GraphHighlightStyle"]使用 GraphHighlightStyle 的内置设置:
DeBruijnGraph[2, 2, GraphHighlight -> {1, 23}, VertexSize -> Small, GraphHighlightStyle -> #, PlotLabel -> #]& /@ Select[ResourceData["GraphHighlightStyle"], # =!= Automatic&]GraphLayout (5)
DeBruijnGraph[2, 2, GraphLayout -> Automatic]Table[DeBruijnGraph[5, 2, GraphLayout -> l, PlotLabel -> l], {l, {"CircularEmbedding", "SpiralEmbedding"}}]Table[DeBruijnGraph[5, 2, GraphLayout -> l, PlotLabel -> l], {l, {"SpringEmbedding", "SpringElectricalEmbedding", "HighDimensionalEmbedding"}}]VertexCoordinates 覆盖了 GraphLayout 坐标:
{DeBruijnGraph[2, 2, GraphLayout -> "SpringElectricalEmbedding"],
DeBruijnGraph[2, 2, GraphLayout -> "SpringElectricalEmbedding", VertexCoordinates -> Table[{i, i}, {i, 0, 3}]]}通过一个布局算法,利用 AbsoluteOptions 提取计算所得的 VertexCoordinates:
DeBruijnGraph[2, 2]AbsoluteOptions[%, VertexCoordinates]PlotTheme (4)
基本主题 (2)
VertexCoordinates (3)
DeBruijnGraph[2, 2]使用 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}]]]DeBruijnGraph[4, 2, VertexCoordinates -> ellipseLayout[16, {2, 1}]]VertexCoordinates 具有比 GraphLayout 更高的优先级:
DeBruijnGraph[2, 2, VertexCoordinates -> Table[{i, i}, {i, 4}], GraphLayout -> "CircularEmbedding"]VertexLabels (13)
DeBruijnGraph[2, 2, VertexLabels -> "Name"]DeBruijnGraph[2, 2, VertexLabels -> {2 -> "one"}]DeBruijnGraph[2, 2, VertexLabels -> Table[i -> Subscript[v, i], {i, 4}]]DeBruijnGraph[2, 2, VertexLabels -> {1 -> [image], 2 -> [image], 3 -> [image]}, ImagePadding -> 20]使用具有符号位置信息的 Placed 来控制标签位置,包括内部位置:
Table[DeBruijnGraph[2, 2, VertexSize -> 0.1, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed["■■■", p], {i, 4}], PlotLabel -> p, ImagePadding -> 20], {p, {Before, After, Below, Above}}]pl = {{Before, Below}, {After, Below}, {Before, Above}, {After, Above}};Table[DeBruijnGraph[2, 2, VertexSize -> 0.1, VertexShapeFunction -> "Square", ImagePadding -> 20, VertexLabels -> Table[i -> Placed["■■■", p], {i, 4}], PlotLabel -> p], {p, pl}]Table[DeBruijnGraph[2, 2, VertexSize -> 0.35, VertexLabels -> Table[i -> Placed["■■■", p], {i, 4}], VertexShapeFunction -> "Square", PlotLabel -> p], {p, {Left, Top, Right, Bottom}}]pl = {{Left, Bottom}, {Right, Bottom}, {Left, Top}, {Right, Top}};Table[DeBruijnGraph[2, 2, VertexSize -> 0.35, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed["■■■", p], {i, 4}], PlotLabel -> p], {p, pl}]Table[DeBruijnGraph[2, 2, VertexSize -> 0.35, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed[[image], p], {i, 4}], PlotLabel -> p, BaselinePosition -> Bottom], {p, {{0, 0}, {1 / 2, 1 / 2}, {1, 1}}}]Table[DeBruijnGraph[2, 2, VertexSize -> 0.35, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed[[image], {{1, 1}, p}], {i, 4}], PlotLabel -> p, BaselinePosition -> Bottom], {p, {{0, 0}, {1 / 2, 1 / 2}, {1, 1}}}]DeBruijnGraph[2, 2, VertexLabels -> {1 -> Placed[{"lbl1", "lbl2"}, {Above, Below}]}]DeBruijnGraph[2, 2, VertexLabels -> {1 -> Placed[{"lbl1", "lbl2", "lbl3", "lbl4"}, {Above, After, Below, Before}]}]使用 Placed 的变量来控制格式,包括 Tooltip:
DeBruijnGraph[2, 2, VertexLabels -> Placed["Name", Tooltip]]或者 StatusArea:
DeBruijnGraph[2, 2, VertexLabels -> Placed["Name", StatusArea]]rotateLabel[lab_] := Rotate[lab, 45Degree]DeBruijnGraph[2, 2, VertexLabels -> Table[i -> Placed["xxx", Below, rotateLabel], {i, 4}]]panelLabel[lab_] := Panel[lab, FrameMargins -> 0, Background -> StandardBlue]DeBruijnGraph[2, 2, VertexLabels -> Table[i -> Placed["xxx", Center, panelLabel], {i, 4}]]hyperlinkLabel[lab_] := Hyperlink[lab, "http://www.wolfram.com"]DeBruijnGraph[2, 2, VertexLabels -> Table[i -> Placed["xxx", Center, hyperlinkLabel], {i, 4}]]VertexShape (5)
将任意 Graphics、Image 或者 Graphics3D 作为顶点形状使用:
Table[DeBruijnGraph[2, 2, VertexShape -> s, VertexSize -> Medium], {s, {[image], [image], [image]}}]DeBruijnGraph[2, 2, VertexShape -> {2 -> [image]}, VertexSize -> Tiny]VertexShape 可以与 VertexSize 合起来使用:
Table[DeBruijnGraph[2, 2, VertexSize -> s, VertexShape -> [image], PlotLabel -> s], {s, {Small, Large}}]VertexShape 不受 VertexStyle 影响:
DeBruijnGraph[2, 2, VertexSize -> 0.3, VertexShape -> [image], VertexStyle -> Blue]VertexShapeFunction 具有比 VertexShape 更高的优先级:
DeBruijnGraph[2, 2, VertexSize -> 0.2, VertexShapeFunction -> "Square", VertexShape -> [image]]VertexShapeFunction (10)
获取 VertexShapeFunction 的内置设置列表:
ResourceData["VertexShapeFunction"]使用 VertexShapeFunction 在 "Basic" 集合中的内置设置:
ResourceData["VertexShapeFunction", "Basic"]Table[DeBruijnGraph[2, 2, VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, {"Triangle", "Square", "Rectangle", "Pentagon", "Hexagon", "Octagon"}}]Table[DeBruijnGraph[2, 2, VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, {"DownTrapezoid", "UpTrapezoid", "Parallelogram", "FiveDown", "Circle", "Diamond", "Star", "Capsule"}}]使用 VertexShapeFunction 在 "Rounded" 集合中的内置设置:
ResourceData["VertexShapeFunction", "Rounded"]Table[DeBruijnGraph[2, 2, VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, ResourceData["VertexShapeFunction", "Rounded"]}]使用 VertexShapeFunction 在 "Concave" 集合中的内置设置:
ResourceData["VertexShapeFunction", "Concave"]Table[DeBruijnGraph[2, 2, VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, ResourceData["VertexShapeFunction", "Concave"]}]DeBruijnGraph[2, 2, VertexShapeFunction -> { 1 -> "Square"}, VertexSize -> 0.2]DeBruijnGraph[2, 2, VertexShapeFunction -> { 1 -> "Square", "Triangle"}, VertexSize -> 0.2]DeBruijnGraph[2, 2, 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}}]
];DeBruijnGraph[2, 2, VertexShapeFunction -> vf, VertexSize -> 0.2]VertexShapeFunction 可以与 VertexStyle 合起来使用:
vf1[{xc_, yc_}, name_, {w_, h_}] := Rectangle[{xc - w, yc - h}, {xc + w, yc + h}]DeBruijnGraph[2, 2, 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}]}DeBruijnGraph[2, 2, VertexSize -> 0.2, VertexStyle -> Blue, VertexShapeFunction -> vf2]VertexShapeFunction 可以与 VertexSize 合起来使用:
DeBruijnGraph[2, 2, VertexShapeFunction -> "Star", VertexSize -> {1 -> Small, Medium}]VertexShapeFunction 具有比 VertexShape 更高的优先级:
DeBruijnGraph[2, 2, VertexSize -> 0.3, VertexShapeFunction -> "Star", VertexShape -> [image]]VertexSize (8)
DeBruijnGraph[2, 2, VertexSize -> Automatic]Table[DeBruijnGraph[2, 2, VertexSize -> s, PlotLabel -> s], {s, {Tiny, Small, Medium, Large}}]Table[DeBruijnGraph[2, 2, VertexSize -> s, PlotLabel -> s], {s, 0.1, 1, 0.3}]Table[DeBruijnGraph[2, 2, VertexSize -> {"Scaled", s}, PlotLabel -> {"Scaled", s}], {s, 0.1, 1, 0.3}]Table[DeBruijnGraph[2, 2, VertexSize -> s, PlotLabel -> s], {s, {{0.1, 0.2}, {0.2, 0.1}}}]DeBruijnGraph[2, 2, VertexSize -> {1 -> 0.2, 2 -> 0.3}]VertexSize 可以与 VertexShapeFunction 合起来使用:
Table[DeBruijnGraph[2, 2, VertexSize -> s, VertexShapeFunction -> "Square", PlotLabel -> s], {s, {0.05, 0.1, 0.2}}]VertexSize 可以与 VertexShape 合起来使用:
Table[DeBruijnGraph[2, 2, VertexSize -> s, VertexShape -> [image], PlotLabel -> s], {s, {0.1, 0.2, 0.4}}]VertexStyle (5)
Table[DeBruijnGraph[2, 2, VertexStyle -> style, VertexSize -> 0.3, PlotLabel -> style], {style, {Yellow, EdgeForm[Dashed]}}]DeBruijnGraph[2, 2, 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}]DeBruijnGraph[2, 2, 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}]}DeBruijnGraph[2, 2, VertexSize -> 0.2, VertexStyle -> Blue, VertexShapeFunction -> vf2]VertexStyle 可以与 BaseStyle 合起来使用:
DeBruijnGraph[2, 2, VertexStyle -> LightBlue, BaseStyle -> EdgeForm[Dotted], VertexSize -> 0.2]VertexStyle 具有比 BaseStyle 更高的优先级:
DeBruijnGraph[2, 2, VertexStyle -> LightBlue, BaseStyle -> Gray, VertexSize -> 0.2]VertexShape 不受 VertexStyle 影响:
DeBruijnGraph[2, 2, VertexSize -> 0.2, VertexShape -> [image], VertexStyle -> Blue]VertexWeight (2)
应用 (6)
De Bruijn 图的 GraphCenter:
Table[HighlightGraph[#, GraphCenter[#]]&[DeBruijnGraph[2, i, VertexSize -> 0.2]], {i, 2, 4}]Table[HighlightGraph[#, GraphPeriphery[#]]&[DeBruijnGraph[2, i, VertexSize -> 0.2]], {i, 2, 4}]VertexEccentricity[DeBruijnGraph[2, 2], #]& /@ VertexList[DeBruijnGraph[2, 2]]FindVertexEccentricityPath[g_ ? DirectedGraphQ, u_] /; MemberQ[VertexList[g], u] := Module[{d = GraphDistanceMatrix[g], posu, posv, vl = VertexList[g]}, posu = VertexIndex[g, u];
posv = First@First@Position[d[[posu]], Max[d[[posu]]]];
PathGraph[FindShortestPath[g, u, vl[[posv]]], DirectedEdges -> True]]Table[HighlightGraph[g = DeBruijnGraph[2, 2], FindVertexEccentricityPath[g, u]], {u, Range[4]}]Table[GraphRadius[DeBruijnGraph[2, i]], {i, 2, 4}]FindRadiusPath[g_ ? DirectedGraphQ] := Module[{c = First@GraphCenter[g], d, v, pos}, d = Table[GraphDistance[g, c, u], {u, VertexList[g]}];
pos = First@Position[d, Max[d]];
v = First@Part[VertexList[g], pos];
PathGraph[FindShortestPath[g, c, v], DirectedEdges -> True]]Table[HighlightGraph[#, FindRadiusPath[#]]&[DeBruijnGraph[2, i, VertexSize -> Tiny]], {i, 2, 4}]Table[GraphDiameter[DeBruijnGraph[2, i]], {i, 2, 4}]FindDiameterPath[g_ ? DirectedGraphQ] := Module[{d = GraphDistanceMatrix[g], u, v, pos}, pos = First@Position[d, Max[d]];
{u, v} = Part[VertexList[g], pos];
PathGraph[FindShortestPath[g, u, v], DirectedEdges -> True]]Table[HighlightGraph[#, FindDiameterPath[#]]&[DeBruijnGraph[2, i, VertexSize -> Tiny]], {i, 2, 4}]突出显示 DeBruijnGraph 的顶点度:
HighlightCentrality[g_, cc_] := HighlightGraph[g, Table[Style[VertexList[g][[i]], ColorData["TemperatureMap"][cc[[i]] / Max[cc]]], {i, VertexCount[g]}]]g = DeBruijnGraph[3, 2, VertexSize -> Large];HighlightCentrality[g, VertexDegree[g]]HighlightCentrality[g, ClosenessCentrality[g]]HighlightCentrality[g, EigenvectorCentrality[g]]属性和关系 (4)
DeBruijnGraph[m,n] 具有
个顶点:
VertexCount[DeBruijnGraph[m, n]]DeBruijnGraph[m,n] 具有
条边:
EdgeCount[DeBruijnGraph[m, n]]mat = AdjacencyMatrix[DeBruijnGraph[m = 2, 3]];(Plus@@mat)//Normal(Plus@@Transpose[mat])//NormalDeBruijnGraph[m,n] 是具有相同符号的 DeBruijnGraph[m,n-1] 的线图:
{LineGraph[DeBruijnGraph[2, 1]], DeBruijnGraph[2, 2]}可能存在的问题 (1)
设置 DirectedEdges->False 不应用于 DeBruijnGraph:
DeBruijnGraph[2, 2, DirectedEdges -> False]相关指南
-
▪
- 图的构建与表示
文本
Wolfram Research (2010),DeBruijnGraph,Wolfram 语言函数,https://reference.wolfram.com/language/ref/DeBruijnGraph.html.
CMS
Wolfram 语言. 2010. "DeBruijnGraph." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/DeBruijnGraph.html.
APA
Wolfram 语言. (2010). DeBruijnGraph. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/DeBruijnGraph.html 年
BibTeX
@misc{reference.wolfram_2026_debruijngraph, author="Wolfram Research", title="{DeBruijnGraph}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/DeBruijnGraph.html}", note=[Accessed: 10-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_debruijngraph, organization={Wolfram Research}, title={DeBruijnGraph}, year={2010}, url={https://reference.wolfram.com/language/ref/DeBruijnGraph.html}, note=[Accessed: 10-September-2026]}