I have an adjacency matrix of a directed acyclic graph represented by a 2D array:
[[0, 4, 3, 0]
[0, 0, 0, 1]
[0, 3, 0, 1]
[2, 0, 0, 0]]
Is there a Python module or a quick code snippet that can run Dijkstra’s Algorithm on this data type? The Python cookbook uses a priority dictionary I believe, but I’d really like to keep it in a 2D array. Any help would be appreciated.
networkx might fit your needs:
See also: networkx.dijkstra_path