ドキュメンテーションヘルプ センタードキュメンテーション
このページの翻訳は最新ではありません。ここをクリックして、英語の最新版を参照してください。
グラフ内のノードを検出
k = findnode(G,nodeID)
例
k = findnode(G,nodeID) は、グラフ G 内で名前またはインデックスが nodeID であるノードの数値ノード ID k を返します。ノードがグラフ内にない場合、数値ノード ID は 0 です。
k
G
nodeID
すべて折りたたむ
グラフを作成し、名前が 'AB' および 'BC' のノードの数値ノード インデックスを求めます。
'AB'
'BC'
s = {'AA' 'AA' 'AA' 'AB' 'AC' 'BB'}; t = {'BA' 'BB' 'BC' 'BA' 'AB' 'BC'}; G = graph(s,t)
G = graph with properties: Edges: [6x1 table] Nodes: [6x1 table]
k = findnode(G,{'AB' 'BC'})
k = 2×1 5 4
k には、指定した各ノードについて G.Nodes.Name の行インデックスが含まれます。
G.Nodes.Name
graph
digraph
入力グラフ。graph オブジェクトまたは digraph オブジェクトとして指定します。無向グラフの作成には graph を、有向グラフの作成には digraph を使用します。
例: G = graph(1,2)
G = graph(1,2)
例: G = digraph([1 2],[2 3])
G = digraph([1 2],[2 3])
ノード識別子。1 つ以上のノード インデックスまたはノード名として指定します。
次の表に、1 つ以上のノードを数値ノード インデックスまたはノード名のいずれかで参照するさまざまな方法を示します。
スカラー
例: 1
1
ベクトル
例: [1 2 3]
[1 2 3]
文字ベクトル
例: 'A'
'A'
文字ベクトルの cell 配列
例: {'A' 'B' 'C'}
{'A' 'B' 'C'}
string スカラー
例: "A"
"A"
string 配列
例: ["A" "B" "C"]
["A" "B" "C"]
例: k = findnode(G,'Chicago') は、グラフ G 内で名前が 'Chicago' のノードの数値ノード ID を返します。
k = findnode(G,'Chicago')
'Chicago'
データ型: char | cell | string
char
cell
string
数値ノード ID。スカラーまたは列ベクトルとして返されます。k の値は、G.Nodes(k,:) のインデックスです。
G.Nodes(k,:)
digraph | findedge | graph | numnodes
findedge
numnodes
この例の変更されたバージョンがあります。編集された方の例を開きますか?
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office