一、igraph软件包创建图和网络
igraph 是一个独立的库,底层是 C,上层有 Python 和 R 接口,主要做图和网络方面的计算,附带绘图功能。...二、例题
eg1.有weight的图
require(igraph)
d = data.frame(p1 = c('a', 'b', 'c'),
p2 = c('b', 'c', 'a'),
weight...注释:R语言设定颜色的方法
library(grDevices);
ramp <- colorRamp(c("red", "white","blue"));
ramp(seq(0, 1, length...邻接矩阵的图
library(igraph)
cells<-c(0,0,1,0,1,1,0,1,0,0,0,0,0,0,0,0,1,0,1,1,0,1,0,0,0,0,0,0,1,1,0,3,0,3,3,3,0,0,0,0,0,0,0,0,3,0,3,1,1,1,0,0,0,0,0,0,1,1...V(g) #返回图g的顶点
E(g) #返回图g的边
4.图形建立:
(1)
> g=graph(c(1,2,5,6,1,4),n=6,directed=T)
> plot(g)
(2)
>g=graph.formula