【问题标题】:Shortest Path calculations crashes with igraph r - maximum number of nodes?最短路径计算因 igraph r 崩溃 - 最大节点数?
【发布时间】:2021-09-30 03:14:42
【问题描述】:

igraph::shortest.paths 函数是否有最大节点数?

以下代码在具有 128GB RAM 的 Windows 10 下使 RStudio Version 1.4.1106 中的 Microsoft R Open 4.0.2 崩溃。

问题:

  • 这是因为igraph的功能吗

  • 这和本地 RAM 有关系吗?

  • 什么是替代品?也许使用cppRouting 包?

      library(igraph)
      c1 <- sample(1:48000, 293631, replace=TRUE)
      c2 <- sample(1:48000, 293631, replace=TRUE)
    
      # column bind the two vectors
      el <- cbind(c1, c2)
    
      # convert matrix as an edgelist into an undirected graph 
      g <- graph.edgelist(el, directed=FALSE)
    
      # obtain distance matrix with shortest path between all pairs of nodes
      t <- shortest.paths(g)
    

【问题讨论】:

标签: r igraph


【解决方案1】:

目前,igraph 没有针对超过最大数据结构大小的稳健检查。但是,作为指导方针,您可以假设不能用带符号的 32 位整数索引的任何东西都不起作用。您的计算将返回的矩阵就是这种情况:

> log2(48000^2)
[1] 31.10149

当超过这些大小时,在 Windows 上尤其容易出现崩溃等问题,其中 long int 类型(目前被 igraph 内部广泛使用)的大小为 32 位,即使在 64 位系统上也是如此。


正在进行的工作是使 igraph 的 C 内核完全准备好 64 位,并让它检测何时超过最大数据结构大小。不幸的是,目前还不清楚如何或是否可以为 igraph 的 R 接口提供 64 位支持,因为 R 本身仍然不支持 64 位整数。但是,未来的版本应该会在超出大小时显示错误而不是崩溃。

【讨论】:

    猜你喜欢
    • 2020-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-02
    • 1970-01-01
    • 1970-01-01
    • 2018-06-23
    相关资源
    最近更新 更多