HararyGraph[k,n]
n 個の頂点が最小で k 連結したグラフ
を生成する.
HararyGraph
HararyGraph[k,n]
n 個の頂点が最小で k 連結したグラフ
を生成する.
詳細とオプション
- HararyGraph[k,n]は n 個の頂点と k 連結した
本の辺を持つグラフである. - HararyGraphにはGraphと同じオプションが使える.
全オプションのリスト
例題
すべて開く すべて閉じる例 (1)
オプション (79)
AnnotationRules (2)
EdgeLabels (7)
HararyGraph[3, 5, EdgeLabels -> {12 -> "Hello"}]el = EdgeList[HararyGraph[3, 5]]HararyGraph[3, 5, EdgeLabels -> Table[el[[i]] -> Subscript["e", i], {i, Length[el]}]]HararyGraph[3, 5, EdgeLabels -> {34 -> [image], 45 -> [image], 12 -> [image]}]Placedを記号位置と一緒に使って辺に沿ったラベルの置き方を制御する:
Table[HararyGraph[3, 5, EdgeLabels -> {12 -> Placed["■■■", p]}, PlotLabel -> p], {p, {"Start", "Middle", "End"}}]Table[HararyGraph[3, 5, EdgeLabels -> {12 -> Placed["■■■", p]}, PlotLabel -> p, BaselinePosition -> Bottom], {p, {0, 1 / 4, 1 / 3}}]Table[HararyGraph[3, 5, EdgeLabels -> {12 -> Placed["■■■", {1 / 2, p}]}, PlotLabel -> p, BaselinePosition -> Bottom], {p, {{0, 0}, {1 / 2, 1 / 2}, {1, 1}}}]HararyGraph[3, 5, EdgeLabels -> {31 -> Placed[{"lbl1", "lbl2"}, {"Start", "End"}]}]HararyGraph[3, 5, EdgeLabels -> {31 -> Placed[{"lbl1", "lbl2", "lbl3"}, {"Start", "Middle", "End"}]}]TooltipとStatusAreaからの値で自動的にラベルを付ける:
HararyGraph[3, 5, EdgeLabels -> Placed["Name", Tooltip]]HararyGraph[3, 5, EdgeLabels -> Placed["Name", StatusArea]]EdgeShapeFunction (6)
EdgeShapeFunctionの組込み設定のリストを得る:
ResourceData["EdgeShapeFunction"]HararyGraph[3, 5, EdgeShapeFunction -> "Line"]Table[HararyGraph[3, 5, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, {"BoxLine", "DiamondLine", "DotLine"}}]Table[HararyGraph[3, 5, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, ResourceData["EdgeShapeFunction", "FilledArrow"]}]Table[HararyGraph[3, 5, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, ResourceData["EdgeShapeFunction", "UnfilledArrow"]}]Table[HararyGraph[3, 5, EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, ResourceData["EdgeShapeFunction", "CarvedArrow"]}]HararyGraph[3, 5, EdgeShapeFunction -> {12 -> "DotLine"}]HararyGraph[3, 5, EdgeShapeFunction -> {12 -> "BoxLine", "DotLine"}]ef[pts_List, e_] :=
Block[{s = 0.015, g = [image]}, {Arrowheads[{{s, 0.33, g}, {s, 0.67, g}}], Arrow[pts]}]HararyGraph[3, 5, EdgeShapeFunction -> ef]EdgeShapeFunctionはEdgeStyleと組み合せることができる:
HararyGraph[3, 5, EdgeStyle -> Blue, EdgeShapeFunction -> (Line[#1]&)]EdgeShapeFunctionはEdgeStyleより優先順位が高い:
HararyGraph[3, 5, EdgeStyle -> Blue, EdgeShapeFunction -> ({Red, Line[#1]}&)]EdgeStyle (2)
EdgeWeight (2)
HararyGraph[3, 5, EdgeWeight -> RandomInteger[5, 8]]WeightedAdjacencyMatrix[%]//MatrixFormHararyGraph[3, 5, EdgeWeight -> {a, b, c, d, e, f, g, h}]WeightedAdjacencyMatrix[%]//MatrixFormGraphHighlight (3)
HararyGraph[3, 5, VertexSize -> Tiny, GraphHighlight -> {1}]HararyGraph[3, 5, VertexSize -> Tiny, GraphHighlight -> {23}]HararyGraph[3, 5, VertexSize -> Tiny, GraphHighlight -> {1, 2, 12, 15}]GraphHighlightStyle (2)
GraphHighlightStyleの組込み設定のリストを得る:
ResourceData["GraphHighlightStyle"]GraphHighlightStyleの組込み設定を使う:
HararyGraph[3, 5, GraphHighlight -> {1, 23}, VertexSize -> Small, GraphHighlightStyle -> #, PlotLabel -> #]& /@ Select[ResourceData["GraphHighlightStyle"], # =!= Automatic&]GraphLayout (5)
HararyGraph[3, 5, GraphLayout -> Automatic]Table[HararyGraph[3, 20, GraphLayout -> l, PlotLabel -> l], {l, {"CircularEmbedding", "SpiralEmbedding"}}]Table[HararyGraph[3, 20, GraphLayout -> l, PlotLabel -> l], {l, {"SpringEmbedding", "SpringElectricalEmbedding", "HighDimensionalEmbedding"}}]VertexCoordinatesはGraphLayoutの座標を無効にする:
{HararyGraph[3, 5, GraphLayout -> "SpringElectricalEmbedding"],
HararyGraph[3, 5, GraphLayout -> "SpringElectricalEmbedding", VertexCoordinates -> Table[{i, i}, {i, 0, 4}]]}AbsoluteOptionsを使ってレイアウトアルゴリズムで計算されたVertexCoordinatesを抽出する:
HararyGraph[3, 5]AbsoluteOptions[%, VertexCoordinates]PlotTheme (4)
基本テーマ (2)
VertexCoordinates (3)
HararyGraph[3, 5]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}]]]HararyGraph[3, 20, VertexCoordinates -> ellipseLayout[20, {2, 1}]]VertexCoordinatesはGraphLayoutより優先順位が高い:
HararyGraph[3, 5, VertexCoordinates -> Table[{i, i}, {i, 5}], GraphLayout -> "CircularEmbedding"]VertexLabels (13)
HararyGraph[3, 5, VertexLabels -> "Name"]HararyGraph[3, 5, VertexLabels -> {2 -> "one"}]HararyGraph[3, 5, VertexLabels -> Table[i -> Subscript[v, i], {i, 5}]]HararyGraph[3, 5, VertexLabels -> {1 -> [image], 2 -> [image], 3 -> [image]}]Placedを記号位置と一緒に使って外側の位置を含むラベルの制御を行う:
Table[HararyGraph[3, 5, VertexSize -> 0.1, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed["■■■", p], {i, 5}], PlotLabel -> p, ImagePadding -> 20], {p, {Before, After, Below, Above}}]pl = {{Before, Below}, {After, Below}, {Before, Above}, {After, Above}};Table[HararyGraph[3, 5, VertexSize -> 0.1, VertexShapeFunction -> "Square", ImagePadding -> 20, VertexLabels -> Table[i -> Placed["■■■", p], {i, 5}], PlotLabel -> p], {p, pl}]Table[HararyGraph[3, 5, VertexSize -> 0.35, VertexLabels -> Table[i -> Placed["■■■", p], {i, 5}], VertexShapeFunction -> "Square", PlotLabel -> p], {p, {Left, Top, Right, Bottom}}]pl = {{Left, Bottom}, {Right, Bottom}, {Left, Top}, {Right, Top}};Table[HararyGraph[3, 5, VertexSize -> 0.35, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed["■■■", p], {i, 5}], PlotLabel -> p], {p, pl}]Table[HararyGraph[3, 5, VertexSize -> 0.25, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed[[image], p], {i, 5}], PlotLabel -> p, BaselinePosition -> Bottom], {p, {{0, 0}, {1 / 2, 1 / 2}, {1, 1}}}]すべてのラベルを頂点の右上のコーナー位置に置いてラベル内の座標を変化させる:
Table[HararyGraph[3, 5, VertexSize -> 0.35, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed[[image], {{1, 1}, p}], {i, 5}], PlotLabel -> p, BaselinePosition -> Bottom], {p, {{0, 0}, {1 / 2, 1 / 2}, {1, 1}}}]HararyGraph[3, 5, VertexLabels -> {1 -> Placed[{"lbl1", "lbl2"}, {Above, Below}]}]HararyGraph[3, 5, VertexLabels -> {1 -> Placed[{"lbl1", "lbl2", "lbl3", "lbl4"}, {Above, After, Below, Before}]}]Placedの引数を使ってTooltipを含むフォーマットを制御する:
HararyGraph[3, 5, VertexLabels -> Placed["Name", Tooltip]]あるいはStatusAreaを含むフォーマットを制御する:
HararyGraph[3, 5, VertexLabels -> Placed["Name", StatusArea]]rotateLabel[lab_] := Rotate[lab, 45Degree]HararyGraph[3, 5, VertexLabels -> Table[i -> Placed["xxx", Below, rotateLabel], {i, 5}]]panelLabel[lab_] := Panel[lab, FrameMargins -> 0, Background -> StandardGray]HararyGraph[3, 5, VertexLabels -> Table[i -> Placed["xxx", Center, panelLabel], {i, 5}]]hyperlinkLabel[lab_] := Hyperlink[lab, "http://www.wolfram.com"]HararyGraph[3, 5, VertexLabels -> Table[i -> Placed["xxx", Center, hyperlinkLabel], {i, 5}]]VertexShape (5)
Graphics,ImageあるいはGraphics3Dを頂点の形として使う:
Table[HararyGraph[3, 5, VertexShape -> s, VertexSize -> Medium], {s, {[image], [image], [image]}}]HararyGraph[3, 5, VertexShape -> {2 -> [image]}, VertexSize -> Medium]VertexShapeはVertexSizeと組み合せることができる:
Table[HararyGraph[3, 5, VertexSize -> s, VertexShape -> [image], PlotLabel -> s], {s, {Small, Large}}]VertexShapeはVertexStyleの影響を受けない:
HararyGraph[3, 5, VertexSize -> 0.2, VertexShape -> [image], VertexStyle -> Blue]VertexShapeFunctionはVertexShapeより優先順位が高い:
HararyGraph[3, 5, VertexSize -> 0.2, VertexShapeFunction -> "Square", VertexShape -> [image]]VertexShapeFunction (10)
VertexShapeFunction組込みコレクションのリストを得る:
ResourceData["VertexShapeFunction"]"Basic"コレクションのVertexShapeFunctionの組込み設定を使う:
ResourceData["VertexShapeFunction", "Basic"]Table[HararyGraph[3, 5, VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, {"Triangle", "Square", "Rectangle", "Pentagon", "Hexagon", "Octagon"}}]Table[HararyGraph[3, 5, VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, {"DownTrapezoid", "UpTrapezoid", "Parallelogram", "FiveDown", "Circle", "Diamond", "Star", "Capsule"}}]"Rounded"コレクションのVertexShapeFunctionの組込み設定を使う:
ResourceData["VertexShapeFunction", "Rounded"]Table[HararyGraph[3, 5, VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, ResourceData["VertexShapeFunction", "Rounded"]}]"Concave"コレクションのVertexShapeFunctionの組込み設定を使う:
ResourceData["VertexShapeFunction", "Concave"]Table[HararyGraph[3, 5, VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, ResourceData["VertexShapeFunction", "Concave"]}]HararyGraph[3, 5, VertexShapeFunction -> { 1 -> "Square"}, VertexSize -> 0.2]HararyGraph[3, 5, VertexShapeFunction -> { 1 -> "Square", "Triangle"}, VertexSize -> 0.2]HararyGraph[3, 5, 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}}]
];HararyGraph[3, 5, VertexShapeFunction -> vf, VertexSize -> 0.2]VertexShapeFunctionはVertexStyleと組み合せることができる:
vf1[{xc_, yc_}, name_, {w_, h_}] := Rectangle[{xc - w, yc - h}, {xc + w, yc + h}]HararyGraph[3, 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}]}HararyGraph[3, 5, VertexSize -> 0.2, VertexStyle -> Blue, VertexShapeFunction -> vf2]VertexShapeFunctionはVertexSizeと組み合せることができる:
HararyGraph[3, 5, VertexShapeFunction -> "Star", VertexSize -> {1 -> Small, Medium}]VertexShapeFunctionはVertexShapeより優先順位が高い:
HararyGraph[3, 5, VertexSize -> 0.3, VertexShapeFunction -> "Star", VertexShape -> [image]]VertexSize (8)
HararyGraph[3, 5, VertexSize -> Automatic]Table[HararyGraph[3, 5, VertexSize -> s, PlotLabel -> s], {s, {Tiny, Small, Medium, Large}}]Table[HararyGraph[3, 5, VertexSize -> s, PlotLabel -> s], {s, 0.1, 1, 0.3}]Table[HararyGraph[3, 5, VertexSize -> {"Scaled", s}, PlotLabel -> {"Scaled", s}], {s, 0.1, 1, 0.3}]Table[HararyGraph[3, 5, VertexSize -> s, PlotLabel -> s], {s, {{0.1, 0.2}, {0.2, 0.1}}}]HararyGraph[3, 5, VertexSize -> {1 -> 0.2, 2 -> 0.3}]VertexSizeはVertexShapeFunctionと組み合せることができる:
Table[HararyGraph[3, 5, VertexSize -> s, VertexShapeFunction -> "Square", PlotLabel -> s], {s, {0.05, 0.1, 0.2}}]VertexSizeはVertexShapeと組み合せることができる:
Table[HararyGraph[3, 5, VertexSize -> s, VertexShape -> [image], PlotLabel -> s], {s, {0.1, 0.2, 0.4}}]VertexStyle (5)
Table[HararyGraph[3, 5, VertexStyle -> style, VertexSize -> 0.3, PlotLabel -> style], {style, {Yellow, EdgeForm[Dashed]}}]HararyGraph[3, 5, 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}]HararyGraph[3, 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}]}HararyGraph[3, 5, VertexSize -> 0.2, VertexStyle -> Blue, VertexShapeFunction -> vf2]VertexSizeはBaseStyleと組み合せることができる:
HararyGraph[3, 5, VertexStyle -> LightBlue, BaseStyle -> EdgeForm[Dotted], VertexSize -> 0.2]VertexSizeはBaseStyleより優先順位が高い:
HararyGraph[3, 5, VertexStyle -> LightBlue, BaseStyle -> Gray, VertexSize -> 0.2]VertexShapeはVertexStyleの影響を受けない:
HararyGraph[3, 5, VertexSize -> 0.2, VertexShape -> [image], VertexStyle -> Blue]VertexWeight (2)
アプリケーション (7)
HararyグラフのGraphCenter:
Table[HighlightGraph[#, GraphCenter[#]]&[HararyGraph[i, 6, VertexSize -> Small]], {i, 2, 5}]Table[HighlightGraph[#, GraphPeriphery[#]]&[HararyGraph[i, 6, VertexSize -> Small]], {i, 2, 5}]VertexEccentricity[HararyGraph[4, 6], #]& /@ VertexList[HararyGraph[4, 6]]FindVertexEccentricityPath[g_ ? UndirectedGraphQ, 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]]]]]Table[HighlightGraph[g = HararyGraph[4, 6], FindVertexEccentricityPath[g, u]], {u, Range[4]}]Table[GraphRadius[HararyGraph[i, 6]], {i, 2, 5}]FindRadiusPath[g_ ? UndirectedGraphQ] := 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]]]Table[HighlightGraph[#, FindRadiusPath[#]]&[HararyGraph[i, 6, VertexSize -> Tiny]], {i, 2, 5}]Table[GraphDiameter[HararyGraph[i, 6]], {i, 2, 5}]FindDiameterPath[g_ ? UndirectedGraphQ] := Module[{d = GraphDistanceMatrix[g], u, v, pos}, pos = First@Position[d, Max[d]];
{u, v} = Part[VertexList[g], pos];
PathGraph[FindShortestPath[g, u, v]]]Table[HighlightGraph[#, FindDiameterPath[#]]&[HararyGraph[i, 6, VertexSize -> Tiny]], {i, 2, 5}]HararyGraphの頂点次数をハイライトする:
HighlightCentrality[g_, cc_] := HighlightGraph[g, Table[Style[VertexList[g][[i]], ColorData["TemperatureMap"][cc[[i]] / Max[cc]]], {i, VertexCount[g]}]];g = HararyGraph[3, 7, VertexSize -> Large];HighlightCentrality[g, VertexDegree[g]]HighlightCentrality[g, ClosenessCentrality[g]]HighlightCentrality[g, EigenvectorCentrality[g]]
から
までの頂点連結性は
から
までの頂点独立経路の数である:
g = HararyGraph[2, 8, VertexLabels -> "Name"]{HighlightGraph[g, 1 <-> 8],
HighlightGraph[g, Table[i <-> (i + 1), {i, 1, 7}]]}HararyGraph[k,n]の頂点連結性度は k である:
g = HararyGraph[3, 8, VertexLabels -> "Name", ImagePadding -> 10];{HighlightGraph[g, PathGraph[{1, 8}]],
HighlightGraph[g, PathGraph[{1, 2, 3, 4, 8}]],
HighlightGraph[g, PathGraph[{1, 5, 6, 7, 8}]]}特性と関係 (5)
HararyGraph[k,n]には n 個の頂点がある:
VertexCount[HararyGraph[k, n]]HararyGraph[k,n]には
辺がある:
EdgeCount[HararyGraph[k, n]]CycleGraphはHararyGraphの特殊ケースである:
Table[CycleGraph[n], {n, 3, 5}]Table[HararyGraph[2, n], {n, 3, 5}]CompleteGraphはHararyGraphの特殊ケースである:
Table[CompleteGraph[n], {n, 3, 5}]Table[HararyGraph[n - 1, n], {n, 3, 5}]CirculantGraphはHararyGraphの特殊ケースである:
Table[HararyGraph[3, 2i], {i, 2, 4}]Table[CirculantGraph[2i, {1, i}], {i, 2, 4}]考えられる問題 (1)
DirectedEdges->Trueの設定はHararyGraphには適用されない:
HararyGraph[5, 8, DirectedEdges -> True]関連するガイド
テキスト
Wolfram Research (2010), HararyGraph, Wolfram言語関数, https://reference.wolfram.com/language/ref/HararyGraph.html.
CMS
Wolfram Language. 2010. "HararyGraph." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/HararyGraph.html.
APA
Wolfram Language. (2010). HararyGraph. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HararyGraph.html
BibTeX
@misc{reference.wolfram_2026_hararygraph, author="Wolfram Research", title="{HararyGraph}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/HararyGraph.html}", note=[Accessed: 03-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_hararygraph, organization={Wolfram Research}, title={HararyGraph}, year={2010}, url={https://reference.wolfram.com/language/ref/HararyGraph.html}, note=[Accessed: 03-November-2026]}