Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 如何创建igraph对象列表_List_Loops_Igraph - Fatal编程技术网

List 如何创建igraph对象列表

List 如何创建igraph对象列表,list,loops,igraph,List,Loops,Igraph,我有很多igraph对象,我想创建一个列表,在循环中使用它们。我知道我试图生成的列表是对象的名称列表,因此我的循环无法工作。如何创建IGRAPHE objetcs列表?最简单的方法可能是将网络拆分为一个列表,其中每个社区的唯一值对应一个元素,然后将图形构建代码应用于每个片段,将每个片段的结果存储在另一个列表中。在R中有几种方法可以做这种事情,其中之一就是使用 “拉普拉” #基于社区独特的价值观将网络分割成碎片 netSplit是R中的吗?或者Python?请提供一个最低限度的工作示例。 #Bre

我有很多igraph对象,我想创建一个列表,在循环中使用它们。我知道我试图生成的列表是对象的名称列表,因此我的循环无法工作。如何创建IGRAPHE objetcs列表?

最简单的方法可能是将网络拆分为一个列表,其中每个社区的唯一值对应一个元素,然后将图形构建代码应用于每个片段,将每个片段的结果存储在另一个列表中。在R中有几种方法可以做这种事情,其中之一就是使用 “拉普拉”

#基于社区独特的价值观将网络分割成碎片

netSplit是R中的吗?或者Python?请提供一个最低限度的工作示例。
#Break net into pieces based on unique values of community
netSplit <- split(net,net$community)

#Define a function to apply to each element of netSplit
myFun <- function(dataPiece){
    netEdges <- NULL

    for (idi in c("nom1", "nom2", "nom3")) {
        netEdge <- dataPiece[c("id", idi)]
        names(netEdge) <- c("id", "friendID")
        netEdge$weight <- 1
        netEdges <- rbind(netEdges, netEdge)
    }

    g <- graph.data.frame(netEdges, directed=TRUE)
    #This will return the graph itself; you could change the function
    # to return other values calculated on the graph
    g
}