WeightedAdjacencyGraph[wmat]
重み付き隣接行列 wmat を持つグラフを与える.
WeightedAdjacencyGraph[{v1,v2,…},wmat]
頂点 vi,重み付き隣接行列 wmat のグラフを与える.
WeightedAdjacencyGraph[{v1,v2,…},wmat,val]
非連結辺の重みが val であると解釈されるグラフを与える.
WeightedAdjacencyGraph
WeightedAdjacencyGraph[wmat]
重み付き隣接行列 wmat を持つグラフを与える.
WeightedAdjacencyGraph[{v1,v2,…},wmat]
頂点 vi,重み付き隣接行列 wmat のグラフを与える.
WeightedAdjacencyGraph[{v1,v2,…},wmat,val]
非連結辺の重みが val であると解釈されるグラフを与える.
詳細とオプション
- WeightedAdjacencyGraph[wmat]はWeightedAdjacencyGraph[{1,2,…,n},wmat]に等しい.ただし,wmat の次元は
×
である. - WeightedAdjacencyGraphにはGraphと同じオブションが使える.
- WeightedAdjacencyGraph[{v1,v2,…},wmat]は,事実上,WeightedAdjacencyGraph[{v1,v2,…},wmat,Infinity]に等しい.
- オプションDirectedEdgesを使って有向グラフを構築するか無向グラフを構築するかが制御できる.
- WeightedAdjacencyGraphで使えるDirectedEdgesの設定値
-
Automatic wmat が対称の場合は無向グラフ True 有向グラフを構築 False 無向グラフを構築
全オプションのリスト
例題
すべて開く すべて閉じる例 (2)
スコープ (8)
WeightedAdjacencyGraph[(| | | | |
| - | - | - | - |
| ∞ | 1 | 2 | ∞ |
| 1 | ∞ | 1 | 1 |
| 2 | 1 | ∞ | 3 |
| ∞ | 1 | 3 | ∞ |)]WeightedAdjacencyGraph[(| | | | |
| - | - | - | - |
| ∞ | 2 | ∞ | ∞ |
| 1 | ∞ | ∞ | ∞ |
| 1 | 1 | ∞ | ∞ |
| 3 | 1 | ∞ | ∞ |)]DirectedEdgesを使って有向グラフを構築するか無向グラフを構築するかを制御する:
WeightedAdjacencyGraph[(| | | | |
| - | - | - | - |
| ∞ | 1 | 2 | ∞ |
| 1 | ∞ | 1 | 1 |
| 2 | 1 | ∞ | 3 |
| ∞ | 1 | 3 | ∞ |), DirectedEdges -> True]{WeightedAdjacencyGraph[(| | | | |
| - | - | - | - |
| 1 | 1 | 2 | ∞ |
| 1 | ∞ | 1 | 1 |
| 2 | 1 | ∞ | 3 |
| ∞ | 1 | 3 | ∞ |)], WeightedAdjacencyGraph[(| | | | |
| - | - | - | - |
| ∞ | 2 | ∞ | ∞ |
| 1 | ∞ | ∞ | ∞ |
| 1 | 1 | 1 | ∞ |
| 3 | 1 | ∞ | ∞ |)]}SparseArrayオブジェクトを使って隣接行列を指定する:
WeightedAdjacencyGraph[SparseArray[{{i_, j_} /; (i ≠ j) -> 1}, {6, 6}, ∞]]VertexList@WeightedAdjacencyGraph[(| | | | |
| - | - | - | - |
| ∞ | 2 | 1 | ∞ |
| 2 | ∞ | 1 | 1 |
| 1 | 1 | ∞ | 1 |
| ∞ | 1 | 1 | ∞ |)]VertexList@WeightedAdjacencyGraph[{a, b, c, d}, (| | | | |
| - | - | - | - |
| ∞ | 2 | 1 | ∞ |
| 2 | ∞ | 1 | 1 |
| 1 | 1 | ∞ | 1 |
| ∞ | 1 | 1 | ∞ |)]WeightedAdjacencyGraph[(| | | | |
| - | - | - | - |
| 0 | 1 | 2 | 0 |
| 1 | 0 | 1 | 1 |
| 2 | 1 | 0 | 3 |
| 0 | 1 | 3 | 0 |), 0]WeightedAdjacencyGraphは大きい行列に使うことができる:
SparseArray[{Band[{2, 1}] -> 1, Band[{3, 1}] -> 1}, {10^6, 10^6}, ∞]Timing[WeightedAdjacencyGraph[%]//EdgeCount]オプション (83)
AnnotationRules (3)
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), AnnotationRules -> {1 -> {VertexLabels -> "hello"}}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), AnnotationRules -> {12 -> {EdgeLabels -> "hello"}}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), AnnotationRules -> {"GraphProperties" -> {"Message" -> "hello"}}]AnnotationValue[%, "Message"]DirectedEdges (3)
WeightedAdjacencyGraph[(| | | | |
| - | - | - | - |
| ∞ | 2 | 1 | ∞ |
| 2 | ∞ | 1 | 1 |
| 1 | 1 | ∞ | 1 |
| ∞ | 1 | 1 | ∞ |)]DirectedEdges->Trueを使って有向グラフを生成する:
WeightedAdjacencyGraph[(| | | | |
| - | - | - | - |
| ∞ | 2 | 1 | ∞ |
| 2 | ∞ | 1 | 1 |
| 1 | 1 | ∞ | 1 |
| ∞ | 1 | 1 | ∞ |), DirectedEdges -> True, EdgeStyle -> Arrowheads[Medium]]WeightedAdjacencyGraph[(| | | | |
| - | - | - | - |
| ∞ | 2 | ∞ | ∞ |
| 1 | ∞ | ∞ | ∞ |
| 1 | 1 | ∞ | ∞ |
| 3 | 1 | ∞ | ∞ |), EdgeStyle -> Arrowheads[Medium]]EdgeLabels (8)
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeLabels -> {12 -> "Hello"}]el = {12, 23, 31};WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeLabels -> Table[el[[i]] -> Subscript["e", i], {i, Length[el]}]]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeLabels -> {12 -> [image], 23 -> [image], 13 -> [image]}]Placedを記号位置と一緒に使って辺に沿ったラベルの置き方を制御する:
Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeLabels -> {12 -> Placed["■■■", p]}, PlotLabel -> p], {p, {"Start", "Middle", "End"}}]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeLabels -> {12 -> Placed["■■■", p]}, PlotLabel -> p, BaselinePosition -> Bottom], {p, {0, 1 / 2, 1}}]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeLabels -> {12 -> Placed["■■■", {1 / 2, p}]}, PlotLabel -> p, BaselinePosition -> Bottom], {p, {{0, 0}, {1 / 2, 1 / 2}, {1, 1}}}]EdgeLabelsを使って複数のラベルを置く:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeLabels -> {31 -> Placed[{"lbl1", "lbl2"}, {"Start", "End"}]}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeLabels -> {31 -> Placed[{"lbl1", "lbl2", "lbl3"}, {"Start", "Middle", "End"}]}]TooltipとStatusAreaからの値で自動的にラベルを付ける:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeLabels -> Placed["Name", Tooltip]]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeLabels -> Placed["Name", StatusArea]]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 2 |
| 1 | ∞ | 1 |
| 2 | 1 | ∞ |), EdgeLabels -> "EdgeWeight"]EdgeShapeFunction (6)
EdgeShapeFunctionの組込み設定を得る:
ResourceData["EdgeShapeFunction"]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeShapeFunction -> "Line"]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, {"BoxLine", "DiamondLine", "DotLine"}}]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | ∞ |
| ∞ | ∞ | 3 |
| 2 | ∞ | ∞ |), EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, ResourceData["EdgeShapeFunction", "FilledArrow"]}]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | ∞ |
| ∞ | ∞ | 3 |
| 2 | ∞ | ∞ |), EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, ResourceData["EdgeShapeFunction", "UnfilledArrow"]}]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | ∞ |
| ∞ | ∞ | 3 |
| 2 | ∞ | ∞ |), EdgeShapeFunction -> {{ef, "ArrowSize" -> 0.1}}, PlotLabel -> ef], {ef, ResourceData["EdgeShapeFunction", "CarvedArrow"]}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | ∞ |
| ∞ | ∞ | 3 |
| 2 | ∞ | ∞ |), EdgeShapeFunction -> {12 -> "FilledArrow"}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | ∞ |
| ∞ | ∞ | 3 |
| 2 | ∞ | ∞ |), 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]}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeShapeFunction -> ef]EdgeShapeFunctionはEdgeStyleと組み合せることができる:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeStyle -> Blue, EdgeShapeFunction -> (Line[#1]&)]EdgeShapeFunctionはEdgeStyleより優先順位が高い:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeStyle -> Blue, EdgeShapeFunction -> ({Red, Line[#1]}&)]EdgeStyle (2)
Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeStyle -> style, PlotLabel -> style], {style, {Gray, Dashed, Thick}}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), EdgeStyle -> {12 -> Blue, 13 -> Dashed}]EdgeWeight (1)
GraphHighlight (3)
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> Tiny, GraphHighlight -> {1}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> Tiny, GraphHighlight -> {23}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> Tiny, GraphHighlight -> {1, 2, 13, 23}]GraphHighlightStyle (2)
GraphHighlightStyleの組込み設定のリストを得る:
ResourceData["GraphHighlightStyle"]GraphHighlightStyleの組込み設定を使う:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), GraphHighlight -> {1, 23}, VertexSize -> Small, GraphHighlightStyle -> #, PlotLabel -> #]& /@ Select[ResourceData["GraphHighlightStyle"], # =!= Automatic&]GraphLayout (5)
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), GraphLayout -> Automatic]m = WeightedAdjacencyMatrix[GridGraph[{10, 10}]];Table[WeightedAdjacencyGraph[m, 0, GraphLayout -> l, PlotLabel -> l], {l, {"CircularEmbedding", "SpiralEmbedding"}}]m = WeightedAdjacencyMatrix[GridGraph[{10, 10}]];Table[WeightedAdjacencyGraph[m, 0, GraphLayout -> l, PlotLabel -> l], {l, {"SpringEmbedding", "SpringElectricalEmbedding", "HighDimensionalEmbedding"}}]VertexCoordinatesはGraphLayoutの座標を無効にする:
{WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), GraphLayout -> "SpringElectricalEmbedding"],
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), GraphLayout -> "SpringElectricalEmbedding", VertexCoordinates -> Table[{i, i}, {i, 0, 2}]]}AbsoluteOptionsを使ってレイアウトアルゴリズムで計算されたVertexCoordinatesを抽出する:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |)]AbsoluteOptions[%, VertexCoordinates]PlotTheme (4)
基本テーマ (2)
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), PlotTheme -> "Business"]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), PlotTheme -> "Monochrome"]特徴テーマ (2)
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), PlotTheme -> "LargeGraph"]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), PlotTheme -> "ClassicDiagram"]VertexCoordinates (3)
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |)]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}]]]m = WeightedAdjacencyMatrix[PathGraph[Range[20]]];WeightedAdjacencyGraph[m, 0, VertexCoordinates -> ellipseLayout[20, {2, 1}]]VertexCoordinatesはGraphLayoutより優先順位が高い:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexCoordinates -> Table[{i, i}, {i, 3}], GraphLayout -> "CircularEmbedding"]VertexLabels (13)
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexLabels -> "Name"]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexLabels -> {1 -> "one"}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexLabels -> Table[i -> Subscript[v, i], {i, 3}]]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexLabels -> {1 -> [image], 2 -> [image], 3 -> [image]}, ImagePadding -> 30]Placedを記号位置と一緒に使って外側位置を含むラベルの置き方を制御する:
Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> 0.1, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed["■■■", p], {i, 3}], PlotLabel -> p, ImagePadding -> 20], {p, {Before, After, Below, Above}}]pl = {{Before, Below}, {After, Below}, {Before, Above}, {After, Above}};Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> 0.1, VertexShapeFunction -> "Square", ImagePadding -> 20, VertexLabels -> Table[i -> Placed["■■■", p], {i, 3}], PlotLabel -> p], {p, pl}]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> 0.25, VertexLabels -> Table[i -> Placed["■■■", p], {i, 3}], VertexShapeFunction -> "Square", PlotLabel -> p], {p, {Left, Top, Right, Bottom}}]pl = {{Left, Bottom}, {Right, Bottom}, {Left, Top}, {Right, Top}};Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> 0.25, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed["■■■", p], {i, 3}], PlotLabel -> p], {p, pl}]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> 0.25, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed[[image], p], {i, 3}], PlotLabel -> p, BaselinePosition -> Bottom], {p, {{0, 0}, {1 / 2, 1 / 2}, {1, 1}}}]すべてのラベルを頂点の右上コーナー位置に置き,ラベル内の座標を変化させる:
Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> 0.35, VertexShapeFunction -> "Square", VertexLabels -> Table[i -> Placed[[image], {{1, 1}, p}], {i, 3}], PlotLabel -> p, BaselinePosition -> Bottom], {p, {{0, 0}, {1 / 2, 1 / 2}, {1, 1}}}]Placedをラッパーで使って複数のラベルを置く:
WeightedAdjacencyGraph[{1, 2, Labeled[3, Placed[{"lbl1", "lbl2"}, {Above, Below}]]}, (| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |)]WeightedAdjacencyGraph[{1, 2, Labeled[3, Placed[{"lbl1", "lbl2", "lbl3", "lbl4"}, {Above, After, Below, Before}]]}, (| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |)]VertexLabelsを使って複数のラベルを置く:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexLabels -> {3 -> Placed[{"lbl1", "lbl2"}, {Above, Below}]}]Placedの引数を使ってTooltipを含むフォーマットを制御する:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexLabels -> Placed["Name", Tooltip]]あるいはStatusAreaを含むフォーマットを制御する:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexLabels -> Placed["Name", StatusArea]]rotateLabel[lbl_] := Rotate[lbl, 45Degree]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexLabels -> Table[i -> Placed["xxx", Below, rotateLabel], {i, 3}]]panelLabel[lbl_] := Panel[lbl, FrameMargins -> 0, Background -> Lighter[Yellow, 0.7]]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexLabels -> Table[i -> Placed["xxx", Center, panelLabel], {i, 3}]]hyperlinkLabel[lbl_] := Hyperlink[lbl, "http://www.wolfram.com"]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexLabels -> Table[i -> Placed["xxx", Center, hyperlinkLabel], {i, 3}]]VertexShape (5)
Graphics,ImageあるいはGraphics3Dを頂点の形に使う:
Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexShape -> s, VertexSize -> Medium], {s, {[image], [image], [image]}}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexShape -> {2 -> [image]}, VertexSize -> Small]VertexShapeはVertexSizeと組み合せることができる:
Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> s, VertexShape -> [image], PlotLabel -> s], {s, {Small, Large}}]VertexShapeはVertexStyleの影響を受けない:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> 0.2, VertexShape -> [image], VertexStyle -> Blue]VertexShapeFunctionはVertexShapeより優先順位が高い:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> 0.2, VertexShapeFunction -> "Square", VertexShape -> [image]]VertexShapeFunction (10)
組込みのVertexShapeFunctionコレクションのリストを得る:
ResourceData["VertexShapeFunction"]"Basic"コレクションのVertexShapeFunctionの組込み設定を使う:
ResourceData["VertexShapeFunction", "Basic"]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, {"Triangle", "Square", "Rectangle", "Pentagon", "Hexagon", "Octagon"}}]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, {"DownTrapezoid", "UpTrapezoid", "Parallelogram", "FiveDown", "Circle", "Diamond", "Star", "Capsule"}}]"Rounded"コレクションのVertexShapeFunctionの組込み設定を使う:
ResourceData["VertexShapeFunction", "Rounded"]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, ResourceData["VertexShapeFunction", "Rounded"]}]"Concave"コレクションのVertexShapeFunctionの組込み設定を使う:
ResourceData["VertexShapeFunction", "Concave"]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexShapeFunction -> vf, VertexSize -> 0.2, PlotLabel -> vf], {vf, ResourceData["VertexShapeFunction", "Concave"]}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexShapeFunction -> { 1 -> "Square"}, VertexSize -> 0.2]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexShapeFunction -> { 1 -> "Square", "Triangle"}, VertexSize -> 0.2]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), 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}}]
];WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexShapeFunction -> vf, VertexSize -> 0.2]VertexShapeFunctionはVertexStyleと組み合せることができる:
vf1[{xc_, yc_}, name_, {w_, h_}] := Rectangle[{xc - w, yc - h}, {xc + w, yc + h}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), 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}]}WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> 0.2, VertexStyle -> Blue, VertexShapeFunction -> vf2]VertexShapeFunctionはVertexSizeと組み合せることができる:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexShapeFunction -> "Star", VertexSize -> {1 -> Small, Medium}]VertexShapeFunctionはVertexShapeより優先順位が高い:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> 0.3, VertexShapeFunction -> "Star", VertexShape -> [image]]VertexSize (8)
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> Automatic]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> s, PlotLabel -> s], {s, {Tiny, Small, Medium, Large}}]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> s, PlotLabel -> s], {s, 0.1, 1, 0.3}]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> {"Scaled", s}, PlotLabel -> {"Scaled", s}], {s, 0.1, 1, 0.3}]Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> s, PlotLabel -> s], {s, {{0.1, 0.2}, {0.2, 0.1}}}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> {1 -> 0.2, 2 -> 0.3}]VertexSizeはVertexShapeFunctionと組み合せることができる:
Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> s, VertexShapeFunction -> "Square", PlotLabel -> s], {s, {0.05, 0.1, 0.2}}]VertexSizeはVertexShapeと組み合せることができる:
Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> s, VertexShape -> [image], PlotLabel -> s], {s, {0.1, 0.2, 0.4}}]VertexStyle (5)
Table[WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexStyle -> style, VertexSize -> 0.2, PlotLabel -> style], {style, {Yellow, EdgeForm[Dashed]}}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), 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}]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), 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}]}WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> 0.2, VertexStyle -> Blue, VertexShapeFunction -> vf2]VertexStyleはBaseStyleと組み合せることができる:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexStyle -> LightBlue, BaseStyle -> EdgeForm[Dotted], VertexSize -> 0.2]VertexStyleはBaseStyleより優先順位が高い:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexStyle -> LightBlue, BaseStyle -> Gray, VertexSize -> 0.2]VertexShapeはVertexStyleの影響を受けない:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexSize -> 0.2, VertexShape -> [image], VertexStyle -> Blue]VertexWeight (2)
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexWeight -> {2, 3, 4}]AnnotationValue[{%, 1}, VertexWeight]WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | 1 |
| 1 | ∞ | 1 |
| 1 | 1 | ∞ |), VertexWeight -> {a, b, c}]AnnotationValue[{%, 1}, VertexWeight]特性と関係 (4)
VertexCountとEdgeCountを使って頂点と辺を数える:
g = WeightedAdjacencyGraph[(| | | | | |
| - | - | - | - | - |
| ∞ | 1 | 2 | 1 | 1 |
| 1 | ∞ | 1 | 1 | 1 |
| 2 | 1 | ∞ | 1 | 1 |
| 1 | 1 | 1 | ∞ | 3 |
| 1 | 1 | 1 | 3 | ∞ |)]{VertexCount[g], EdgeCount[g]}VertexListとEdgeListを使って頂点と辺を標準的な順序で列挙する:
g = WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | ∞ |
| ∞ | ∞ | 1 |
| 1 | ∞ | ∞ |)]{VertexList[g], EdgeList[g]}グラフからWeightedAdjacencyMatrixを計算する:
g = WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | ∞ |
| ∞ | ∞ | 1 |
| 1 | ∞ | ∞ |)];(m = WeightedAdjacencyMatrix[g])//MatrixForm対角項がすべて無限である隣接行列は自己ループのないグラフを生成する:
WeightedAdjacencyGraph[(| | | |
| - | - | - |
| ∞ | 1 | ∞ |
| ∞ | ∞ | 1 |
| 1 | ∞ | ∞ |)]LoopFreeGraphQ[%]関連するガイド
-
▪
- グラフと行列 ▪
- グラフの特性 ▪
- グラフのアノテーション
テキスト
Wolfram Research (2010), WeightedAdjacencyGraph, Wolfram言語関数, https://reference.wolfram.com/language/ref/WeightedAdjacencyGraph.html (2025年に更新).
CMS
Wolfram Language. 2010. "WeightedAdjacencyGraph." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/WeightedAdjacencyGraph.html.
APA
Wolfram Language. (2010). WeightedAdjacencyGraph. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WeightedAdjacencyGraph.html
BibTeX
@misc{reference.wolfram_2026_weightedadjacencygraph, author="Wolfram Research", title="{WeightedAdjacencyGraph}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/WeightedAdjacencyGraph.html}", note=[Accessed: 20-July-2026]}
BibLaTeX
@online{reference.wolfram_2026_weightedadjacencygraph, organization={Wolfram Research}, title={WeightedAdjacencyGraph}, year={2025}, url={https://reference.wolfram.com/language/ref/WeightedAdjacencyGraph.html}, note=[Accessed: 20-July-2026]}