pywhy-graphs icon indicating copy to clipboard operation
pywhy-graphs copied to clipboard

Convert MAG to PAG

Open adam2392 opened this issue 1 year ago • 5 comments

Is your feature request related to a problem? Please describe. A MAG is a mixed-edge graph with directed and bidirected edges and has the 'maximality' property.

This is a sub-procedure of https://github.com/py-why/pywhy-graphs/pull/73 and will enable that to function properly.

Describe the solution you'd like Implement a function mag_to_pag, which takes in a valid MAG and outputs the corresponding PAG.

Additional context @aryan26roy if you're still interested, this can be the next step before revisiting #73.

I presume tetrad has a function written in java. More importantly, the paper linked in the issue for #73 should contain the relevant algorithm written in the paper to convert a MAG to a PAG.

adam2392 avatar Jul 06 '23 19:07 adam2392

@adam2392 I will take this up.

aryan26roy avatar Jul 10 '23 07:07 aryan26roy

Perhaps it might make sense to also add a function that takes in a mixed-edge graph with directed and/or bidirected edges (e.g. an ADMG without undirected edges) and checks if it is a valid MAG.

According to Zhang 2008 (https://www.jmlr.org/papers/volume9/zhang08a/zhang08a.pdf), check:

  1. does graph contain any directed, or almost directed cycles?
  2. between any two non-adjacent nodes, is there an inducing path? (this is now possible because you have implemented the inducing path algorithm)

This is probably pretty expensive because it scales poorly wrt node count, but imo it's fine as long as we document it because I'm not aware of another cheaper way to check if a MAG is valid. I'm sure a way exists using some fancy Breadth-first-search.

adam2392 avatar Jul 17 '23 19:07 adam2392

@adam2392 so do you want me to add a method for converting PAG to MAG first or the method for checking the validity of an MAG?

aryan26roy avatar Jul 18 '23 04:07 aryan26roy

Perhaps checking validity of a MAG(?). There are some graphical examples in the paper.

adam2392 avatar Jul 18 '23 12:07 adam2392

Yeah that sounds better to me too.

aryan26roy avatar Jul 18 '23 13:07 aryan26roy