I have a network that is connected like the following:
library(igraph)
network <- graph_from_literal(1--2,2--3,3--4,4--5,3--6,6--7,3--8,8--9)
and have the distance between each segment
> data=data.frame(Origin=c(1,2,3,4,3,6,3,8), Destination=c(2,3,4,5,6,7,8,9), km=c(0.3,0.5,0.2,0.1,1,2,0.6,0.4))
> data
Origin Destination km
1 2 0.3
2 3 0.5
3 4 0.2
4 5 0.1
3 6 1.0
6 7 2.0
3 8 0.6
8 9 0.4
I would like to find the distance matrix between all points and I tried using
distMatrix <- shortest.paths(data, v=Origin(data), to=Destination(data))
but cannot make it work.
Thanks!