Source and Target to simmetrical adjacency matrix

5 ビュー (過去 30 日間)
Ferenc Bakó
Ferenc Bakó 2021 年 4 月 28 日
回答済み: Benjamin Großmann 2021 年 4 月 28 日
I would like to ask for help.
I have a Source (nx1) and Target (nx1) table, and I would like to create a simmetrical adjacency matrix (NxN) (0,1).
Could someone help me? Thx.

回答 (1 件)

Benjamin Großmann
Benjamin Großmann 2021 年 4 月 28 日
Use graph(source, target) for undirected graph or digraph(source, target) for directed graph to define a graph. I assume you have an undirected graph since you mention a symmetrical adjacence matrix.
If the graph is defined properly in Matlab, you can calculate a lot of graph related stuff (adjacency, incidence, bfsearch, ...). You can also define the graph with edge-tables/node-tables see doc graph
% sources
source = [1 2 3 4 3 5];
% targets
target = [2 4 1 1 5 1];
% create graph (or digraph)
myGraph = graph(source, target);
% "full" adjacency matrix (default output is sparse)
full(myGraph.adjacency)
% plot the graph
plot(myGraph)

カテゴリ

Help Center および File ExchangeDirected Graphs についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by