Find All Possible Paths from a Single SourceNode to a Single TargetNode Without Visiting Old Paths
Ältere Kommentare anzeigen
Hi All,
If I have node set nodeset=[nodeID x y] of size numberOfNodes x 3. I also have undirected path pathset=[PathID nodeID1 nodeID2] of size PathID x 3. I would like to find all possible paths from a single sourceNode to a single TargetNode. Visiting the previously travelled edge (path) is not allowed because there would be too much solutions. Visiting the previously travelled vertices are allowed.
Is there a function out there in Matlab that can help me do this: Example: AllPaths(nodeset, pathset, sourceNode, TargetNode) output: sets of vector containing PathID's that gives those possible path.
Your help much appreciated. Thank you in advance.
2 Kommentare
Walter Roberson
am 29 Jan. 2018
On undirected graphs, there are an infinite number of paths between any two nodes that are connected indirectly at all.
Someone asked a similar question a couple of months ago; they were trying to investigate centrality of social networks. I was not able to come up with an algorithm which did not come down to breadth-first search or depth-first search.
Steven Lord
am 29 Jan. 2018
If like the person Walter remembers who asked the similar question a couple months ago you're trying to investigate centrality of a graph or digraph, take a look at the centrality function.
Antworten (1)
czeslaw
am 29 Jan. 2018
Bearbeitet: Walter Roberson
am 29 Jan. 2018
6 Kommentare
Walter Roberson
am 29 Jan. 2018
ABCADC is also a valid path.
Steven Lord
am 29 Jan. 2018
From the Google image search, I believe the node labeling the original poster refers to is:
x = [0 1 1 0];
y = [0 0 1 1];
g = graph({'A', 'A', 'A', 'B', 'C'}, ...
{'B', 'C', 'D', 'C', 'D'});
plot(g, 'XData', x, 'YData', y, 'NodeLabelMode', 'auto')
ADAC, ABAC, and ADABC also all seem like valid paths ending up at C. What additional restrictions do you want to impose on a "possible path" that rules out those three cases?
Walter Roberson
am 29 Jan. 2018
When you speak of previously traveled paths, that is a reference to edges, not to vertices. So if you had
A -- B --- C
/\
/ \
D--E
then using the previously traveled path rule, the A to C route would have to permit
ABC
ABDEBC
ADEDBC
Is that what you want? That each different way of traversing a loop should be counted?
If you instead had rule about not visiting any previously visited vertex then only ABC would be permitted in this sample diagram.
Walter Roberson
am 29 Jan. 2018
Sorry I meant ABEDBC
Kategorien
Mehr zu Graph and Network Algorithms finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!