4 ms·
I just started using NetworkX a few days ago and was trying to figure out a way to find all paths in a DAG from a source node to a destination node, with the re
by Xcelerate 4y ago
I just started using NetworkX a few days ago and was trying to figure out a way to find all paths in a DAG from a source node to a destination node, with the requirement that no path is a superpath of any other path.
I ended up writing my own approach that iterates through all pairs of paths but have been bothered since then that I couldn’t find a function in NetworkX to do this; I’m sure it probably exists but I don’t know the right terminology to search for it. Anyone know what this function might be called?
- math_dandy 4y agoWill nx.all_simple_paths do the job? (A simple path is a path with no repeated nodes.)
- ironSkillet 4y agoI am trying to imagine how it is even possible for this to happen in a DAG. One path from A to B cannot be a strict subset of another (because this implies a cycle) - I unless you mean something else by "superpath".
- Xcelerate 4y agoIf you have paths [A-B-C-Z, A-B-Z, A-D-Z], path A-B-C-Z would be eliminated from that set since it is a superpath of A-B-Z. Is my terminology incorrect?
- ironSkillet 4y agoAh, I see what you mean - I was not thinking about the problem correctly.