Description
Is your feature request related to a problem? Please describe.
We should expose an API (there is one untested really rn) for exporting to the following packages:
- tigramite (3D time-series graph that supports time-series DAG, ADMG, PAG) -> WIP
- pgmpy (DAG and PDAG)
- causal-learn (currently we have this implemented) -> done
- dagitty (DAG, ADMG) -> handled by pygraphviz
- pcalg -> done
- networkx to a DiGraph with a specific structure
- numpy (tigramite, causal-learn, pcalg are all numpy-like array structures) -> done
- ananke -> @jaron-lee to handle
- tetrad text -> done
- bnlearn -> handled by pygraphviz I think
This will enable pywhy-graphs to be interoperable across many other packages and also allow other users to take their graphs and convert to pywhy-graphs for the sake of using it in dodiscover
and dowhy
.
Describe the solution you'd like
If the other package is not in R, we can directly test roundtrip compatibility.
If the other package is in R, we should just do some basic testing that the format is "as expected". I think loading in R runtime is a whole other beast we don't want to figure out how to do in the CI pipeline.
The solution requires the following for each export:
io roundtrip: That is the basic graph structure should be preserved. Some metadata might be lost depending on the format each package stores graphs in. When possible, metadata should be preserved. A unit test would look like the following where the edge and node structure is preserved.
pcalg_G = pywhy_graphs.export(G, 'pcalg')
G_copy = pywhy_graphs.import(G, 'pcalg')
for edge_type in G.edge_types:
assert nx.is_isomorphic(G.get_graphs(edge_type), G_copy.get_graphs(edge_type))
Additional context
n/a