change the distance matrix to cost
matrix2cost(net, distance)
net
the network structure
distance
distance matrix
the vector of cost