-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH] Add the ability to find Proper Possibly Directed Paths in a Graph #111
Comments
@adam2392 I have a question: The paper defines a proper directed path as follows: "A possibly directed path or possibly causal path from X to Y is a path from X to Y that does not contain an arrowhead pointing in the direction of X." Does this mean any edge (including undirected edge) is fine as long as an arrowhead doesn't point in the direction of X? |
Yep! These are all valid
|
@adam2392 for this I will need to first know all the paths from X to Y regardless of edge type. Is there a function that already does that? |
No, but one can possibly just convert to an undirected graph and then run: https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.simple_paths.all_simple_paths.html#all-simple-paths Not "as efficient" cuz of the conversion, but we can just leave an in-line comment there. |
@adam2392 continuing the conversation, if I just convert to an undirected graph and run "all_simple_paths" then I need to find a way to identify any edges that might contain an arrowhead pointing towards X. Once I convert to an undirected graph, I loose this information. One way is to do this is
|
Yeah I think it's pretty inefficient, but the only other way I can think of is a BFS/DFS style algorithm that just keeps track of edge types along each path. However, I'm okay with a more inefficient algorithm initially and an inline comment documenting why its inefficient. |
Actually, I think the BFS/DFS style approach would be easier to implement. Since all I will have to do is check for a backwards arrow at each edge while keeping track of all the possible paths. For any path to be invalid, either it has a backwards arrow or it doesn't lead to Y. Otherwise, return all paths. |
Of course, this will be more memory intensive since I will have to keep all the possible paths in memory, which makes me wonder whether this approach would in fact be worse for larger graphs. |
On second thought, in method 1, both the steps are essentially BFS/DFS with all the paths being kept track of in memory. This would mean the same memory intensive procedure being done twice. |
Sounds good! |
Is your feature request related to a problem? Please describe.
This is in continuation of PR #1148 in Dowhy. First PR in an effort to provide seamless integration with Dowhy.
Describe the solution you'd like
A couple of functions that can take a graphs and find Proper Possibly Directed Paths in a graph.
The text was updated successfully, but these errors were encountered: