I am trying to design a network (more precisely a directed acyclic graph) with specific edge lengths. The data is on the form of an edge list, and for each edge, there is an associated length. It might take the form of an edgelist matrix and a vector containing edge length, such as :
> edgelist = matrix( c("A","B","B","A","A","B","C","D","F","G"), ncol = 2 )
> length = c(1, 8, 7, 6, 5)
> edgelist
[,1] [,2]
[1,] "A" "B"
[2,] "B" "C"
[3,] "B" "D"
[4,] "A" "F"
[5,] "A" "G"
> length
[1] 1 8 7 6 5
I can plot the network using
> network = as.network(edgelist, matrix.type = "edgelist", directed = TRUE)
> plot(network)
The network is directed and, it won't have directed cycles (it can have, if we ignore direction, some sort of simple cycles - they will be very rare in practice), and it shouldn't be impossible from a geometric point of view to scale the edge length to the value of the third column in 2D. It is to be noted that many nodes will have a degree > 3 .
My question is : is there an algorithm, implemented in R (for the moment, I use the network
package, but I am not limited to it and can use for instance igrap
if necessary) that will allow me to draw such a graph ? I have looked into various functions (from network and other packages), but haven't found any.
PS: This is a partly network analysis partly R-coding question, I hope it is on the right site here (rather than Stackoverflow).