gpt4 book ai didi

r - R : converting a bipartite graph into a one-mode affiliation network中的igraph

转载 作者:行者123 更新时间:2023-12-04 12:25:17 26 4
gpt4 key购买 nike

以下是我使用 igraph 创建的玩具数据集在 Rstudio 中为恐怖分子肇事者及其目标的双边网络。以下规范适用于两种类型顶点之间的有向二分关系:

set.seed(1234)

df <- data.frame(
perpetrator <- c(
'Armed Islamic Group (GIA)',
'Armed Islamic Group (GIA)',
'Algerian Islamic Extremists',
'Islamic Salvation Front (FIS)',
'Unindentified Activists',
'Armed Islamic Group (GIA)',
'Armata di Liberazione Naziunale (ALN)',
'Armed Islamic Group (GIA)',
'Islamist Extremists',
'Muslim Fundamentalists'),
target <- c(
'Unnamed Civilians',
'Unnamed Civilians',
'Unnamed Civilians',
'Government Buildings',
'Police Station',
'Soldiers',
'Terrorist Group',
'Unnamed Civilians',
'Police Patrol',
'Police Patrol'),
stringsAsFactors = TRUE)

net <- graph.edgelist(as.matrix(df))

V(net)$type <- bipartite.mapping(net)$type

proj_net <- bipartite.projection(net)

plot(net,
main = "Bipartite Projection of Algerian Terror Network",
layout=-layout.bipartite(net)[,2:1])

我的问题: 我如何将其转换为单一模式(单方)从属网络,其中顶点是恐怖分子肇事者,边缘是肇事者之间的共同目标? 我的直觉告诉我我必须进行矩阵乘法并绘制邻接矩阵,但是我在遵循本论坛中的一些示例脚本时没有成功。我意识到在这个玩具示例中,我将有一些隔离和一些二元组,但是一旦我掌握了机制,我想将此转换过程扩展到更大的数据集

其次,对于单模规范,中心性、密度和传递性等描述性度量是否与其他非分图相同,或者二分网络中的描述性干扰是否需要不同的网络结构度量?

最佳答案

你不是已经拥有了吗?

df  <- data.frame(perpetrator=c("A","A","B","C","D","A","E","A","F","G"),
target =c("a","a","a","b","c","d","e","a","f","f"))
net <- graph.edgelist(as.matrix(df))
V(net)$type <- bipartite.mapping(net)$type
par(mfrow=c(1,2),mar=c(0,1,1,1))
plot(net, main="Full Network",edge.arrow.size=0.5)
plot(bipartite.projection(net)$proj1,main="Affilitaton Network")


bipartite.projection(...)返回两个图的列表,名为 $proj1$proj2 ,其中有从属网络。所以在这种情况下, AB通过 a 连接, 和 FG通过 f 连接.

关于r - R : converting a bipartite graph into a one-mode affiliation network中的igraph,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27221478/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com