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).

  • $\begingroup$ Using rgraphviz or graphviz or dot are not statistics subjects. $\endgroup$ – Alexis Jul 15 '14 at 17:52
  • $\begingroup$ I am not sure I understand, but I don't use any of these for the moment. Do you mean I should try them, or that the question would be better asked on another site (such as stackoverflow.com) - I must say I did hesitate about that last point. $\endgroup$ – Jean-Baptiste Camps Jul 15 '14 at 17:58
  • $\begingroup$ My mistake on the specific syntax, then: using software to create DAGs is not an appropriate topic for CV in my opinion. $\endgroup$ – Alexis Jul 15 '14 at 18:01
  • 2
    $\begingroup$ Could you expand a bit on what it would mean to "draw" this data structure? One would guess that you want to represent the nodes with point symbols and the edges with some kind of 1D traces connecting those nodes. Could those traces be curved or must they be straight? Do you also want the Euclidean distance in the plot to be directly proportional to the edge lengths? (That can be framed as a multidimensional scaling (MDS) problem.) Do you want to minimize intersections of the images of edges? Any other objectives? $\endgroup$ – whuber Jul 15 '14 at 18:28
  • $\begingroup$ You guessed well : I want the nodes as points (with labels, but that is not a problem) and the arcs as (preferably straight) arrows, and the Euclidean distance indeed proportional to edge length, with minimized intersections. It should not be very complex in this case, as nearly all edges will have one incoming arc and two or three outgoing arcs. $\endgroup$ – Jean-Baptiste Camps Jul 15 '14 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.