Open rahulbshrestha opened 3 weeks ago
(Copying from another comment) I was a bit confused about the direction of the edges. If the adjacency matrix is
np.matrix(
[[0, 0, 1, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 1, 1],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]]
)
the graph is currently,
isn't it supposed to be:
because the typical interpretation of adjacency matrices is rows represent source nodes and columns represent destination nodes. Is this a bug or a conscious decision?
This comes from the for-loop,
for to, from_, coef in zip(dirs[0], dirs[1], adjacency_matrix[idx]):
d.edge(names[from_], names[to], label=str(coef))
@amit-sharma If the design choice for the direction of the edges (adjacency matrix -> graph) is intentional and supposed to be the way it is, then the PR is ready to be merged!
This PR fixes the issue of incorrect edges in
adjacency_matrix_to_graph
when the adjacency matrix is of typenp.matrix
by converting the matrix into a numpy array.Related issue: https://github.com/py-why/dowhy/issues/887