igraph / rigraph

igraph R package
https://r.igraph.org
532 stars 200 forks source link

Failed to load graph using read.graph.ncol #1346

Closed knwng closed 1 month ago

knwng commented 2 months ago

What happens, and what did you expect instead?

Trackback:

Error in read.graph.ncol(file, ...): INTEGER() can only be applied to a 'integer', not a 'double'
Traceback:

1. read_graph(paste(file_path, edge_files[i], sep = ""), format = "ncol", 
 .     directed = TRUE)
2. read.graph.ncol(file, ...)

To reproduce

shell_call <- function(command, ...) {
  result <- system(command, intern = TRUE, ...)
  cat(paste0(result, collapse = "\n"))
}

shell_call("if [[ ! -e gplus.tar.gz ]]; then wget https://snap.stanford.edu/data/gplus.tar.gz; fi")
shell_call("if [[ ! -e gplus.tar.gz ]]; then tar zxf gplus.tar.gz; fi")

remove.packages("igraph")
# install.packages("igraph", version = "1.5.1")
install.packages("devtools")
require(devtools)
install_packages("igraph", version = "1.5.1", repos=c(
    igraph = 'https://igraph.r-universe.dev',
    CRAN = 'https://cloud.r-project.org'
  ))

library ("igraph")

graph = read_graph("gplus/100535338638690515335.edges", format="ncol", directed=TRUE)

System information

It's on a google colab runtime.

Output of sessionInfo():

R version 4.3.3 (2024-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: Etc/UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] igraph_2.0.3

loaded via a namespace (and not attached):
 [1] digest_0.6.29   IRdisplay_1.1   utf8_1.2.2      base64enc_0.1-3
 [5] fastmap_1.1.0   magrittr_2.0.2  glue_1.6.1      pkgconfig_2.0.3
 [9] htmltools_0.5.2 repr_1.1.7      lifecycle_1.0.1 cli_3.2.0      
[13] fansi_1.0.2     vctrs_0.3.8     pbdZMQ_0.3-11   compiler_4.3.3 
[17] tools_4.3.3     evaluate_0.15   pillar_1.7.0    ellipsis_0.3.2 
[21] rlang_1.0.1     jsonlite_1.7.3  crayon_1.5.0    IRkernel_1.3.2 
[25] uuid_1.0-3   
knwng commented 2 months ago

Seems it's related to this commit: https://github.com/igraph/rigraph/commit/c92a172c24c9a7eafee9189ee6e3702520937bd1

It works when downgrade to 1.5.1

szhorvat commented 2 months ago

Reasonable size repro:

library(igraph)
g<-make_graph(c(1,2,2,3))
write_graph(g, 'zoo.ncol', 'ncol')
read_graph('zoo.ncol', 'ncol')
szhorvat commented 2 months ago

Thanks for reporting this and tracking down the offending commit! A PR with a fix is opened now.

maelle commented 1 month ago

I removed the label from the issue since it's also on the PR.