我目前正在使用igraph
使用triad_census(g)
获得给定有向图的traid普查。这将返回16个类中每个类中的三元组计数。
例如,16 3 0 10 1 0 0 0 0 0 0 0 0 0 0 0
但是,我想知道三合会的更多细节,而不是这些摘要统计数据。
即鉴于网络中有16个003
,它们是什么?鉴于该网络有3个012
,它们是什么?
示例:012
的3个三元组是qazxsw poi,qazxsw poi,(john -> emi, jenne)
有没有办法在r或python中这样做?
MWE
图表数据:(cena -> ally, john)
码:
(emi -> peter, david)
所以,我的实际图形如下所示。 http://docs.google.com/viewer?a=v&pid=sites&srcid=ZGVmYXVsdGRvbWFpbnxkYWlzaGl6dWthfGd4OmFmZTI0NjhlMjQ0ZDQ5MQ
如果需要,我很乐意提供更多细节。
似乎没有内置的方法来完成你想要的Networkx。但是,您可以手动浏览每个三元组并定义它属于哪个类:
library(igraph)
#import the sample_dw_adj.csv file:
dat=read.csv(file.choose(),header=TRUE,row.names=1,check.names=FALSE) # read .csv file
m=as.matrix(dat)
net=graph.adjacency(m,mode="directed",weighted=TRUE,diag=FALSE)
plot.igraph(net,vertex.label=V(net)$name,layout=layout.fruchterman.reingold, vertex.label.color="black",edge.color="black",edge.width=E(net)$weight/3, edge.arrow.size=1.5)
如果你想要一个以类作为键的字典,你可以尝试这样的事情: