How to cluster a network?

4 ビュー (過去 30 日間)
abdullah nasser abdullah
abdullah nasser abdullah 2019 年 7 月 13 日
編集済み: abdullah nasser abdullah 2019 年 7 月 17 日
Hello guys,
If I have a network ( Lets call it x) and it is described by the following edges:
x=[1 2 3 4 5 6]; %vertices in the network
Edg =[1 2; 1 3 ; 2 3 ; 3 4 ; 4 5;6 3; 5 6]; %edges
A=graph(Edg(:,1),Edg(:,2));
plot(A)
The graph A looks like this :
matalbg.PNG
If x is devided into two areas (we know the nodes in each area):
x1=[1 2 3];
x2=[3 4 5 6]; %the common vertex is 3
%edges is the same
Now i want to plot each area, so the graph above will be splitted into two graphs and vertix 3 is in both graphs.
To do this i need to write a code which gives the edges in each area, like this:
Edges for x1 [ 1 2; 2 3; 1 3]. Edges for x2 [ 3 6; 3 4; 4 5 ; 5 6].

回答 (1 件)

Akira Agata
Akira Agata 2019 年 7 月 14 日
How about applying biconncomp function?
The following is an example:
% Sample Graph
s = [1 1 2 2 3 4 4 5 6 6 7 7 8];
t = [2 3 3 4 4 5 7 6 7 10 8 9 9];
G = graph(s,t);
% Visualize G
figure
plot(G);
% Apply biconncomp function
bincell = biconncomp(G, 'OutputForm', 'cell');
n = length(bincell);
% Visualize the separated graphs
figure
for ii = 1:n
subplot(2,2,ii)
plot(subgraph(G, bincell{ii}), 'NodeLabel', bincell{ii});
end
Original Graph:
g1.png
Separated graphs:
g2.png
  1 件のコメント
abdullah nasser abdullah
abdullah nasser abdullah 2019 年 7 月 17 日
編集済み: abdullah nasser abdullah 2019 年 7 月 17 日
Many thanks for your answer Mr. Akira,
Your answer perfectly fit if there is only one coupled node between any two areas,
but lets consider that i have more than coupled node like the following:
x=[1 2 3 4 5 6]; %vertices in the network
Edg =[1 2; 1 4 ; 2 3 ; 3 4 ; 4 5;6 3; 5 6]; %edges
G=graph(Edg(:,1),Edg(:,2));
plot(G)
And we want the paritioning to be like this:
Where 3 and 4 are the common node between the two areas.
I want something that work for larger systems; where i know the nodes for each area and i know the coupled nodes between them as well.

サインインしてコメントする。

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by