igraph-help
[Top][All Lists]
Advanced

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

[igraph] Wierd behavior of graph.adjacency ?


From: Ester Lopez
Subject: [igraph] Wierd behavior of graph.adjacency ?
Date: Tue, 10 Jul 2012 09:51:30 +0200

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



reply via email to

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