问题
Write a code that produces the distance matrix from a graph (graph theory), the code should use the adjacency matrix and cannot use any functions from NetworkX module, apart from networkx.adjacency_matrix().
I understand the process of how the distance matrix works. My theory of how the adjacency matrix is involved is that it takes an element that connects two nodes and adds the distance up. For example, lets say i have nodes A, B and C. A is connected to B, and B is connected to C. The distance between two connected nodes is 1. So the distance from A to C would be 2.
My only problem is how i can implement this into a code so that it creates a distance matrix for any given graph.
Thank you for any help, sorry if my explanation is unclear, please let me know if you would like me to clarify anything.
来源:https://stackoverflow.com/questions/55328620/computing-the-distance-matrix-from-an-adjacency-matrix-in-python