Ask Your Question

Revision history [back]

As documented (see D99.distance_matrix? to get the documentation), you can specify the order of the vertices in the columns. Note that some vertices are missing in the order you ask for...

sage: helm111 = {'1':['2','3','4'],'2':['5','4'],'3':['6','4'],'4':['7']}
sage: D99 = Graph(helm111)
sage: D99.distance_matrix(vertices=['1','2','3','5','6','4','7'])
[0 1 1 2 2 1 2]
[1 0 2 1 3 1 2]
[1 2 0 3 1 1 2]
[2 1 3 0 4 2 3]
[2 3 1 4 0 2 3]
[1 1 1 2 2 0 1]
[2 2 2 3 3 1 0]
sage: D99.distance('1', '7')
2
sage: D99.distance('6', '2')
3