Hello everybody!
I want to compute the distance between edges of a small tree:
Land = {1 -> 2, 1 -> 15, 2 -> 3, 2 -> 4, 3 -> 7, 3 -> 8, 15 -> 5,
15 -> 6, 5 -> 9, 5 -> 10, 10 -> 11, 10 -> 12, 6 -> 13, 6 -> 14};
Etiq = {"All", "Flat", "Plain", "tl", "Hills", "Mountain", "fp", "ip",
"rlh", "Lowslope", "hh", "slh", "hm", "lm", "\[Not]Flat"};
Codes = Inner[Rule, Range[Length@Etiq], Etiq, List];
The distance matrix is obtained from:
Gr = Graph[Land, DirectedEdges -> False, VertexLabels -> Codes]
Print@TableForm[GraphDistanceMatrix[Gr],
TableHeadings -> {Etiq, Etiq}];
but something is wrong: the distance between "ip" and "fp" should be 2, while in the table, it's 5! Building myself the table
Dis = Table[
GraphDistance[Gr, i, j], {i, Length@Etiq}, {j, Length@Etiq}];
Print@TableForm[Dis, TableHeadings -> {Etiq, Etiq}];
I could obtain the right distance matrix, but I dont' understand how GraphDistanceMatrix put away the distances! Isn't it misleading?
Regards, Claude