Suppose I have a boolean matrix: (like this one):
X 0 1 2 3
0 1, 1, 1, 1
1 1, 1, 1, 0
2 1, 1, 1, 1
3 1, 0, 1, 1
and I would like to transform it in a graph, in order to find the shortest path between two vertices (I'm going to apply Dijkstra’s algorithm) . I think I allready know how to apply this algorithm in python, the only problem I have is to transform this matrix in a dictionary that could look like this :
graph = {0 : {0:1, 1:1, 2:1, 3:1},
1 : {0:1, 1:1, 2:1},
2 : {0:1, 1:1, 2:1, 3:1},
3 : {0:1, 2:1, 3:1}}
well, I'm not sure that the way I am thinking about it is correct, can somebody help me with this?