/ / igraph usando due layout per diversi nodi - r, igraph

igraph usando due layout per diversi nodi - r, igraph

C'è un modo per tracciare un grafico usando due layout diversi, uno per un insieme di nodi e un altro per tutti gli altri nodi?

Ad esempio, definire che i nodi 1-10 sono tracciati con un layout circolare e tutti gli altri nodi sono disegnati con layout diretto dalla forza.

risposte:

1 per risposta № 1

Si, puoi. Hai solo bisogno di unire due layout diversi.

library(igraph)

gr <- random.graph.game(100, p.or.m = 0.25, type = "gnp")

lay1 <- layout_in_circle(induced_subgraph(gr, 1:20)) ##layouts are just matrices with x, y coordinates
lay2 <- layout_with_fr(induced_subgraph(gr, 21:100)) #I used Fruchterman-Reingold on the subgraph excluding the nodes in the circle but you could include them and then overwrite their layout coordinates with the coordinates for the circle
lay3 <- rbind(lay1+2, lay2) ## I added a scalar to shift the circlular nodes out of the middle of the force-directed layout to make it more obvious.
plot(gr, layout=lay3, vertex.size=8)

inserisci la descrizione dell'immagine qui