Skip to content
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

Exporting graph structure #129

Closed
qvhaelen opened this issue Sep 2, 2021 · 2 comments
Closed

Exporting graph structure #129

qvhaelen opened this issue Sep 2, 2021 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@qvhaelen
Copy link

qvhaelen commented Sep 2, 2021

Hello,

I would like to know if once the graph has been generated using DAGClassifier , is there a built-in mehod to export the structure of the graph, (edges, weight, nodes) in a column format so it can be visaulized using another custom tools?

Thank you

@qvhaelen qvhaelen changed the title Exporting graph structure in txt format Exporting graph structure Sep 2, 2021
@oentaryorj
Copy link
Contributor

oentaryorj commented Sep 3, 2021

Hi @qvhaelen,

We currently don't have a built-in export method. However, since StructureModel extends networkx.DiGraph (see here), you can use networkx's export method. For example, you can export to a .dot file using write_dot function:

import networkx as nx

from causalnex.structure import StructureModel

# Create a model
sm = StructureModel()
sm.add_edges_from([
    ('A', 'C'),
    ('B', 'C'),
])
# Save the model into pygraphviz's dot format
nx.drawing.nx_pydot.write_dot(sm, 'graph.dot')

To export to other formats, you can find out more from networkx's documentation. Hope this helps :)

@oentaryorj oentaryorj self-assigned this Sep 3, 2021
@oentaryorj oentaryorj added the question Further information is requested label Sep 3, 2021
@qvhaelen
Copy link
Author

qvhaelen commented Sep 4, 2021

Dear @oentaryorj thank you for the information. Yes I am already using the networkx functionalities so I guess it should be ok to export graph using networkx exprot function without relying on pygraphiz

@qbphilip qbphilip mentioned this issue Nov 10, 2021
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants