-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
compute_v_structures
output and docstring do not agree
#7385
Comments
It looks to me like the doc_string does not match the function behavior. The function seems to compute triples where the two outer nodes have directed edges to the middle node. It doesn't perform checks on connections between the outer(parent) nodes. Unfortunately the tests do not include this case where the two parents are connected. And the wikipedia reference doesn't actually use the term @maichmueller can you describe how you are using this function? Should it be removed? @adam2392 do you have any thoughts about the Thanks! |
hi @dschult, Otherwise, the way to fix it for computing v-structures would be a simple check on either parent node sharing an edge with the other parent. This is in fact how I am currently using it in my lib:
So I am not doing much more than adding the check for adjacency between the parents to decide if it is a collider or a true v-structure. The definition of v-structure is not completely unambiguous from what I can tell, but for reference, I would mention Pearl's PRIMER, chapter 2 page 50:
The sorting should not happen IMO, as it is not essential to the functionality, yet limits its scope. |
I am +0.5 in favor of this solution if we don't want v-structures. See below
Another possibility is the following code:
We simply need to add a unit-test for having adjacent parents to confirm that triplet is not a "v-structure", or unshielded collider.
Agreed.
Yes I'm not exactly sure why there is sorting here. We can prolly remove it tbh. |
Current Behavior
The docstring of the method
compute_v_structures
indag.py
saysIn particular, the part and the two parent nodes are not adjacent is what seems to disagree with the output of the iterator for a DAG. To my knowledge, in a DAG
G=(V, E)
two nodesa,b
are adjacent if(a,b) in E || (b,a) in E
:Clearly, 2 and 5 are adjacent, yet the function still returns (2,4,5) as a v-structure.
Expected Behavior
The test case above should return an empty list or the docstring should change its specification of v-structures.
Steps to Reproduce
Install
networkx >= 3.1
and run the above commands.Environment
Python version: 3.8 - 3.11
NetworkX version: 3.1 - 3.21
The text was updated successfully, but these errors were encountered: