Skip to content

Commit

Permalink
Fixed graphviz import
Browse files Browse the repository at this point in the history
Signed-off-by: rahulbshrestha <[email protected]>
  • Loading branch information
rahulbshrestha committed Jun 10, 2024
1 parent e22297f commit e85a8f6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dowhy/utils/graph_operations.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
from queue import LifoQueue

import graphviz
import networkx as nx
import numpy as np
from networkx.algorithms.dag import is_directed_acyclic_graph
Expand Down Expand Up @@ -38,6 +37,7 @@ def adjacency_matrix_to_graph(adjacency_matrix, labels=None):
:param labels: List of labels.
:returns: Graph in DOT format.
"""
import graphviz

if adjacency_matrix.ndim != 2:
raise ValueError("Adjacency matrix must have a dimension of 2.")
Expand All @@ -57,9 +57,11 @@ def adjacency_matrix_to_graph(adjacency_matrix, labels=None):
for label in labels:
d.node(label)

for from_, to, coef in zip(dirs[0], dirs[1], adjacency_matrix[idx]):
for to, from_, coef in zip(dirs[0], dirs[1], adjacency_matrix[idx]):
d.edge(labels[from_], labels[to], label=str(coef))

return d


def str_to_dot(string):
"""
Expand Down

0 comments on commit e85a8f6

Please sign in to comment.