Skip to content

Commit 16f868e

Browse files
committed
Added support for XML graphs for speedy reading in
1 parent 16c468d commit 16f868e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

causal_testing/specification/causal_dag.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ def __init__(self, dot_path: str = None, ignore_cycles: bool = False, **attr):
134134
super().__init__(**attr)
135135
self.ignore_cycles = ignore_cycles
136136
if dot_path:
137-
self.graph = nx.DiGraph(nx.nx_pydot.read_dot(dot_path))
137+
if dot_path.endswith(".dot"):
138+
self.graph = nx.DiGraph(nx.nx_pydot.read_dot(dot_path))
139+
elif dot_path.endswith(".xml"):
140+
self.graph = nx.graphml.read_graphml(dot_path)
141+
else:
142+
raise ValueError(f"Unsupported file extension {dot_path}. We only support .dot and .xml files.")
138143
else:
139144
self.graph = nx.DiGraph()
140145

0 commit comments

Comments
 (0)