igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Wierd behavior of graph.adjacency ?


From: Ester López
Subject: Re: [igraph] Wierd behavior of graph.adjacency ?
Date: Wed, 18 Jul 2012 12:52:57 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

Hi Gabor,

Thanks a lot! :)

Kind regards,
Ester
On 07/17/2012 07:50 PM, Gábor Csárdi wrote:
Hi Ester,

I am sorry for the delay. This is a known bug:
https://bugs.launchpad.net/igraph/+bug/1019624

It happens because graph.adjacency does not work if the input matrix
contains integers. The workaround is to convert your matrix to
"numeric" (which means "double", really) before calling
graph.adjacency:

mode(mat) <- "numeric"
graph.adjacency(mat, ...)

Best,
Gabor

On Tue, Jul 10, 2012 at 3:51 AM, Ester Lopez <address@hidden> wrote:
Hi all,

I'm trying to read some directed graphs from a file which looks like:

cat losses1/257-data.826460.84-2419_10_3net.in
1 0 3 0 0 0 3 0 3 0

0 1 0 0 0 3 0 0 0 3

3 0 0 0 0 0 0 0 0 0

0 0 0 0 3 0 0 0 0 0

0 0 0 3 1 3 0 3 0 0

0 3 0 0 3 1 3 0 0 0

3 0 0 0 0 3 0 0 0 0

0 0 0 0 3 0 0 0 0 0

3 0 0 0 0 0 0 0 1 0

0 3 0 0 0 0 0 0 0 0

  Which represents the weighted adjacency matrix. When I read the file in R:

mat <- read.table('losses1/257-data.826460.84-2419_10_3net.in')
mat <- read.table('losses1/257-data.826460.84-2419_10_3net.in')
mat <- as.matrix(mat)
mat
       V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
  [1,]  1  0  3  0  0  0  3  0  3   0
  [2,]  0  1  0  0  0  3  0  0  0   3
  [3,]  3  0  0  0  0  0  0  0  0   0
  [4,]  0  0  0  0  3  0  0  0  0   0
  [5,]  0  0  0  3  1  3  0  3  0   0
  [6,]  0  3  0  0  3  1  3  0  0   0
  [7,]  3  0  0  0  0  3  0  0  0   0
  [8,]  0  0  0  0  3  0  0  0  0   0
  [9,]  3  0  0  0  0  0  0  0  1   0
[10,]  0  3  0  0  0  0  0  0  0   0
gr <- graph.adjacency(mat, weighted=TRUE)
get.adjacency(gr, sparse=FALSE)
     V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
V1   1  1  0  1  1  1  1  0  1   0
V2   1  0  1  0  0  1  1  1  1   1
V3   0  0  1  1  0  1  1  1  1   1
V4   1  0  1  0  0  1  1  1  1   1
V5   1  0  0  0  1  1  1  1  1   0
V6   1  0  1  0  1  1  1  1  1   1
V7   0  0  0  0  0  1  0  1  0   1
V8   1  1  1  1  0  1  1  1  1   1
V9   0  0  1  0  0  1  1  1  1   1
V10  1  0  0  0  0  1  1  1  1   1

E(gr)[2]$weight
[1] 1.482197e-323

I've tried creating by my own the same matrix manually and it works just
fine, but Im not sure why, when I load it from the file it behaves like
this. Also the results slightly differ if I change the dimnames(mat), but
yet not the correct ones.

I'm using igraph "0.6-2" version.

Any idea about what I'm doing wrong?

Thanks a lot,
Ester



_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help








reply via email to

[Prev in Thread] Current Thread [Next in Thread]