[英]Creating a graph structure using igraph in R
I am trying to reproduce the following plot using igraph
in R.我正在尝试使用 R 中的
igraph
重现以下 plot。
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.我不确定如何创建图的拓扑并生成完全相同的图。
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.使用
layout=
参数指定位置,使用V(g)$color
和E(g)$lty
指定顶点颜色和边线类型。
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给予
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.