commands → pathdistance

pathdistance(A,P)

The pathdistance command takes a (square) adjacency matrix A whose entries are edge weights and computes the length of a path P of vertices through A. This is the sum of the edge weights traversed.

Examples

A = [[0,1,4],[1,0,1],[3,1,0]];
pathdistance(A,[0,2]);
	4

pathdistance(A,[0,1,2]);
	2