Find paths in graph that satisfy specific condition
이전 댓글 표시
I have the following graph:
s=[17,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,30,30];
t=[18,19,20,21,22,23,24,25,26,27,28,29,30,8,7,6,5,4,3,2,1,9,10,11,12,13,14,15,16];
x_pos=[-4,-4,-4,-4,-4,-4,-4,-4,4,4,4,4,4,4,4,4,-1,1,-2,-2,2,2,-3,-3,-3,-3,3,3,3,3];
y_pos=[-7,-5,-3,-1,1,3,5,7,7,5,3,1,-1,-3,-5,-7,0,0,4,-4,4,-4,6,2,-2,-6,6,2,-2,-6];
names={'P','Q','O','N','R','S','T','U','C1','B1','A1','Z','Y','X','V','W','A','C','B','E','D','I','H','F','G','M','L','K','J'};
G=graph(s,t);
h=plot(G,'EdgeLabel',names,'XData',x_pos,'YData',y_pos);
and I want to automate finding specific paths in pairs. I explain the workflow:
- Define two extremal nodes and find a path between them that passes through a specific edge;
- Find all other paths that start and end in extremal nodes and cross the first path ONLY in the specified edge.
So for example, I want a path that starts from node 8 and ends in node 5 that passes by edge H (should only be one path); THEN I want to find all paths that start and end in extremal nodes and pass through H but do not cross the first path in any other edges (so it cannot be the same path going from node 7 to node 6, T-I-H-S because it crosses the path in both I and H).
If it is possible to implement such solution, I need it as generic as possible since I would need to iterate it for all edges (not the focus of the question at the moment). Is it possible to have this kind of "conditional pathfinding" in matlab?
댓글 수: 2
Dyuman Joshi
2024년 2월 19일
편집: Dyuman Joshi
2024년 2월 22일
Please show what you have you tried yet.
Kakey Linmart
2024년 2월 19일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
