Select edges that connect subgraphs together

조회 수: 4 (최근 30일)
NA
NA 2020년 4월 8일
편집: NA 2020년 4월 9일
I have a graph like this
M = [1 2; 2 3; 1 3; 4 5; 5 6; 6 7; 4 7;2 4; 5 7; 5 8;11 8; 8 9; 9 10; 10 11;4 12; 12,13; 13 14;12 14];
g = graph(M(:, 1), M(:, 2));
h = plot(g);
I want to find edges that connect subgraphs together
result should be
A = [2,4; 5 8; 4 12]
  댓글 수: 2
Sean de Wolski
Sean de Wolski 2020년 4월 8일
So trying to verbalize the rule: return any edge whose two end nodes are connected to at least two other nodes?
(Also, your data do not include nodes 12/13/14 so [4 12] wouldn't be returned)
NA
NA 2020년 4월 9일
Thanks. I corrected edge set.

댓글을 달려면 로그인하십시오.

채택된 답변

Sean de Wolski
Sean de Wolski 2020년 4월 8일
This works for your sample data set (which does not include nodes 12:14 as shown in the plot. Please test test this, I'm not a graph theory expert so there may be cases where this does not work.
M = [1 2; 2 3; 1 3; 4 5; 5 6; 6 7; 4 7;2 4; 5 7; 5 8;11 8; 8 9; 9 10; 10 11];
g = graph(M(:, 1), M(:, 2));
h = plot(g);
bcg = biconncomp(g).'; % biconnected components
[count, group] = groupcounts(bcg); % How many of each?
edgeidx = ismember(bcg, group(count==1)); % Edges with one count
g.Edges(edgeidx, 1) % Extract
ans =
2×1 table
EndNodes
________
2 4
5 8

추가 답변 (1개)

darova
darova 2020년 4월 8일

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by