Dibra
Dibra

Reputation: 13

Visualizing graph/network with 3 layeres (tripartite) igraph

There are already a topic about tripartite graphs in igraph, but the way they use layout.sugiyama is not good for me. I would like to impose a order for the nodes. Actually, I would like to visualize edge crossing for the tripartite graph. Suppose I have a tripartite graph with 3 nodes in each column. I will have only one edge coming out from each node. The 6 edges could be, for example, (A->E, B->F, C->D, D-> H, E->G, F-> I). Something like that:

      A         D         G         
      B         E         H
      C         F         I

How can I do this using igraph? As I said, I want to see the crossing edges. Thank you.

Upvotes: 1

Views: 960

Answers (1)

lukeA
lukeA

Reputation: 54237

For example, you could do:

library(igraph)
coords <- matrix(c(rep(1:3, each = 3), rep(3:1, 3)), 
                 ncol = 2, 
                 dimnames = list(LETTERS[1:9], c("x", "y")))
g <- graph.formula(A--E, B--F, C--D, D-- H, E--G, F--I)
plot(g, layout = coords[V(g)$name, ])

enter image description here

Upvotes: 2

Related Questions