- As far as I can tell that KKT matrix tells you nothing about connectivity. It only tells you which node belongs to which terminal.
- Do the terminals actually matter. You could certainly store the adjacency matrix for the nodes and completely forget about the terminals.
- Shortest path between what and what?
Find lenght of shortest path from nodal incidence matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello, I want to find the lenght of the shortest path between two nodes out of the given nodal-terminal-incidence-matrix (nti). In the nti the number of rows equals the number of nodes and the number of columns equals the number of terminals. Every connection of two nodes is represented by a single path with two terminals. The first on the first node, second on second node. So for instance for a 4-node graph (see picture),
the nti is
KKT=[1 0 0 0 1 0 0 0;
0 1 0 0 0 0 1 0;
0 0 1 0 0 1 0 0;
0 0 0 1 0 0 0 1];
How can i calculate the adjacency-matrix from this and how can i find now the length of shortest path?
댓글 수: 1
Guillaume
2018년 6월 15일
답변 (2개)
Rostislav Teryaev
2018년 6월 15일
편집: Rostislav Teryaev
2018년 6월 15일
It seems not like an incidence matrix. Incidence matrix represents nodes connections. There are can be two approaches:
1. Terminals as graph nodes
IncTerminals = [1 1 0 0 1 0 0 0
1 1 0 0 0 0 1 0
0 0 1 1 0 1 0 0
0 0 1 1 0 0 0 1
1 0 0 0 1 1 0 0
0 0 1 0 1 1 0 0
0 1 0 0 0 0 1 1
0 0 0 1 0 0 1 1]
2. Nodes as graph nodes
IncNodes = [1 1 1 0
1 1 0 1
1 0 1 1
0 1 1 1]
But I can not remember wether it possible or not to convert incinence matrix to adjacency matrix or build a graph object with it.
But it is possible to build any kind of matrix or graph object if you would set edges as a pairs of nodes (check the doc for graph function). Again two ways:
1. Terminals as graph nodes
s = [1 1 2 3 3 4 5 7]; % Vector of starting nodes
t = [2 5 7 4 6 8 6 8]; % Vector of target nodes
2. Nodes as graph nodes
s = [1 1 2 3]; % Vector of starting nodes
t = [2 3 4 4]; % Vector of target nodes
Now you can create a graph object by
G = graph(s,t);
plotting it by
plot(G)
gives
1. Terminals
2. Nodes
Then you can extract from graph object any matrix you want
Adj = adjacency(G);
or
Inc = incidence(G);
And the shortest path also
P = shortestpath(G,1,3)
참고 항목
카테고리
Help Center 및 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!