gpt4 book ai didi

读取二部图和单模投影

转载 作者:行者123 更新时间:2023-12-02 21:39:53 24 4
gpt4 key购买 nike

如何读取二分图?我尝试了以下代码,但是当我尝试制作 OMP 时,它显示

Error in bipartite.projection(g, types = NULL) : 
Not a bipartite graph, supply `types' argument

这是代码:

edgelist = read.csv("g1.csv",header=FALSE,sep=",")
g = graph.edgelist(as.matrix(edgelist),directed=FALSE)
proj <- bipartite.projection(g,types=NULL)
g2= proj[[1]]
myplot(g2)

g1.csv 1,5 1,4 2,4 3,5

最佳答案

来自文档:

 Bipartite graphs have a ‘type’ vertex attribute in igraph, this is
boolean and ‘FALSE’ for the vertices of the first kind and ‘TRUE’
for vertices of the second kind.

所以请添加一个type顶点属性,它定义哪些顶点属于哪个组。

关于读取二部图和单模投影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20611838/

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