py-why / causal-learn

Causal Discovery in Python. It also includes (conditional) independence tests and score functions.

Home Page:https://causal-learn.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Questions related to graph and adjacency matrix using PC & FCI

asha24choudhary opened this issue · comments

Thank you for this amazing repo. I had two questions.

  1. Is there a possibility to compare the graphs provided by PC & FCI using the networkx library for instance using isomorphic method described here? I was thinking if there was a way to export the graphs that is compatible with networkx library?

  2. I saw that I can get the adjacency matrix in lingam, is there a possibility to get the same using PC/FCI?

Hi, thanks for your interest. It is possible to get the adjacency matrix for PC & FCI as mentioned in the doc as follows:
image

And for FCI (G.graph[i,j]):

image

I don't think there is an existing function for the first point, but I believe transferring the graph class in causal-learn to networkx-like graphs using pywhy-graph might be promising.

Thank you, I found that the causal graph object returned by PC can be visualized by networkx as shown in this doc, however, when I try to do the same using the Graph G returned by FCI it is not possible as the graph class is different in this case. The object returned by PC is 'causallearn.graph.GraphClass.CausalGraph', however, in case of FCI as we get two outputs (graph & edges), the graph object returned by FCI is completely different and I cannot visualise it. I don't know which python script should I edit to define the 'G.to_nx_graph()' method as shown here, that can be used for FCI. Thank you in advance!