与大部份R语言包不同,igraph包没有自带的数据集。
生成图对象是,进行图分析的条件。前面说了,igraph包有8中图对象。文章源自微观生活(93wg.com)微观生活-https://93wg.com/2205.html
薛薇老师的《R语言数据发掘办法及利用》提供了igraph包的利用教程。文章源自微观生活(93wg.com)微观生活-https://93wg.com/2205.html
然而在学习中,我也发现薛老师书中有很过错,需要调剂。文章源自微观生活(93wg.com)微观生活-https://93wg.com/2205.html
下面是相干代码及解释。文章源自微观生活(93wg.com)微观生活-https://93wg.com/2205.html
library文章源自微观生活(93wg.com)微观生活-https://93wg.com/2205.html
薛老师原书是画出四个图,并不好,这句代码不要。文章源自微观生活(93wg.com)微观生活-https://93wg.com/2205.html
set.seed文章源自微观生活(93wg.com)微观生活-https://93wg.com/2205.html
G1<-graph.formula再用plot,就能够看到G1对应图文章源自微观生活(93wg.com)微观生活-https://93wg.com/2205.html
V$label.cex<-0.7文章源自微观生活(93wg.com)微观生活-https://93wg.com/2205.html
E$label<-c文章源自微观生活(93wg.com)微观生活-https://93wg.com/2205.html
E$curved<-TRUE
vcount
ecount
plot
G1<-simplify
G2<-graph.empty
V$name<-V$label<-LETTERS[1:4]
G2<-add.edges)
E$label<-c
E$curved<-TRUE
V$label.cex<-0.7
plot
G3<-graph.empty
V$name<-V$label<-LETTERS[1:9]
G3<-add.edges)
E$label<-c
G3<-set.vertex.attribute)
V[discrete]$shape<-&34;
V[!discrete]$shape<-&34;
G3<-set.vertex.attribute)
E$curved<-TRUE
V$label.cex<-0.7
is.connected
sapply,FUN=subcomponent,graph=G3)
G4<-k.regular.game
V$name<-V$label<-LETTERS[1:10]
以上就是微观生活(93wg.com)关于“R语言igraph包学习(2)——生成无向图”的详细内容,希望对大家有所帮助!
评论