Reputation: 818
I am trying to reproduce the following plot using igraph
in R.
I have the following code:
library(igraph)
edges <- c(1,2, 2,3, 6,8, 6,7, 4,5, 9,10)
g<-graph(edges, n=max(edges), directed=F)
vcount(g)
plot(g, layout = layout.fruchterman.reingold,vertex.label=V(g)$number,
edge.arrow.size=0.5)
I am not sure how to create the topology of the graph and produce the exact same graph.
Upvotes: 1
Views: 221
Reputation: 270075
Use the layout=
argument to specify the positions and V(g)$color
and E(g)$lty
to specify the vertex color and edge line types.
library(igraph)
edges <- c(1,2, 2,3, 6,8, 6,7, 4,5, 9,10, 1,6, 5,10)
x <- c(2, 1, 2, 1, 2, 5, 6, 5, 6, 5)
y <- c(5:1, 5:1)
g <- graph(edges, n=max(edges), directed = FALSE)
V(g)$color <- "yellow"
E(g)$lty <- c(rep(1, 6), 3, 3)
plot(g, layout = cbind(x, y))
giving
Upvotes: 2
Reputation: 79328
library(igraph)
edges <- c(1,2, 2,3, 6,8, 6,7, 4,5, 9,10, 1,6, 5, 10)
g<-graph(edges, n=max(edges), directed=F)
E(g)$lty <- c(rep(1, length(E(g))-2), rep(2,2))
plot(g)
Upvotes: 1