ver 0.6.2 has serious problems importing adjacency matrix

Reported by joax on 2012-06-30
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
igraph
Fix Released
High
Gábor Csárdi

Bug Description

1) importing a matrix like attached below produces a wrong directed graph
0 0 0 0
0 0 0 1
0 0 0 0
2 0 2 0

2) Also displaying id or values from draw menu at tkigraph creates monstrous names.
3) exporting the previously imported matrix also is wrong.
4) the version 0.5.4.1 worked fine, but trying to install it in R ver 2.15.1 on win7 is not possible!

I move back to R ver 2.10 and igraph 0.5.4.1

joax (joax-spec) wrote :
Tamás Nepusz (ntamas) wrote :

Seems like this is indeed a bug; I have assigned this to Gabor since he is the developer of the R interface.

Sample session in which I reproduced the bug:

> data <- read.table("test.adj")
> data
  V1 V2 V3 V4
1 0 0 0 0
2 0 0 0 1
3 0 0 0 0
4 2 0 2 0
> g <- graph.adjacency(as.matrix(data), weighted=T)
> g
IGRAPH DNW- 4 11 --
+ attr: name (v/c), weight (e/n)
> E(g)$weight
 [1] 1.326247e-314 3.458460e-323 4.243992e-314 4.243992e-314 2.126217e-314
 [6] 2.147193e-314 2.121996e-314 2.146890e-314 2.147193e-314 2.146890e-314
[11] 2.126304e-314

Changed in igraph:
importance: Undecided → High
assignee: nobody → Gábor Csárdi (gabor.csardi)
status: New → Confirmed
Gábor Csárdi (gabor.csardi) wrote :

This is indeed a bug. The workaround is to pass a "numeric" matrix to graph.adjacency, instead of a matrix of integers. I.e. this works fine:

> library(igraph)
>
> data <- read.table("bug-1019624.txt")
> data
  V1 V2 V3 V4
1 0 0 0 0
2 0 0 0 1
3 0 0 0 0
4 2 0 2 0
>
> data <- as.matrix(data)
> mode(data) <- "numeric"
>
> g <- graph.adjacency(data, weighted=TRUE)
> g
IGRAPH DNW- 4 3 --
+ attr: name (v/c), weight (e/n)
> E(g)$weight
[1] 1 2 2

Gábor Csárdi (gabor.csardi) wrote :

Fixed in revision #2895 (0.6-main).

Changed in igraph:
status: Confirmed → Fix Released
Changed in igraph:
milestone: none → 0.6.4

The development of igraph has moved to github, so please do not comment on this bug here. You are of course welcome to comment on github, here:
https://github.com/igraph/igraph/issues/110

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers