igraph / xdata-igraph

xdata igraph, has been merged into igraph/igraph
GNU General Public License v2.0
18 stars 3 forks source link

local scan fails for directed graph and mode="all" #18

Closed gaborcsardi closed 10 years ago

gaborcsardi commented 10 years ago
library(igraph)
g <- graph(c(1,2,2,1, 1,3,3,1, 2,4, 3,4, 3,5,5,3, 4,5,5,4))
local.scan(g, mode="all")
local.scan(g, mode="out")
local.scan(g, mode="in")
youngser commented 10 years ago
set.seed(12345)
g1 <- erdos.renyi.game(n=20,p=0.1,directed=T)
g2 <- erdos.renyi.game(n=20,p=0.1,directed=T)
local.scan(g2,g1,k=1,mode="all",weighted=FALSE)

[1] 4.0 1.0 2.0 1.0 2.0 9.5 1.0 2.0 0.0 5.0 2.0 3.0 3.0 4.0 5.0 3.5 5.0 4.0 2.0 [20] 1.0

Note the non-integer numbers? We believe that the correct numbers are [1] 4 1 2 1 1 8 1 2 0 5 2 3 3 4 5 3 5 4 2 1

gaborcsardi commented 10 years ago

Why is this the same bug?

youngser commented 10 years ago

On Jan 13, 2014, at 11:49 AM, Gabor Csardi notifications@github.com wrote:

Why is this the same bug?

Because it's from the same function call (except it takes two graphs this time). Should I open a new case then?

— Reply to this email directly or view it on GitHub.

gaborcsardi commented 10 years ago

Yes please, it is a new bug, unrelated.

On Mon, Jan 13, 2014 at 11:54 AM, youngser notifications@github.com wrote:

On Jan 13, 2014, at 11:49 AM, Gabor Csardi notifications@github.com wrote:

Why is this the same bug?

Because it's from the same function call (except it takes two graphs this time). Should I open a new case then?

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHubhttps://github.com/igraph/xdata-igraph/issues/18#issuecomment-32187646 .

youngser commented 10 years ago

Gabor, It seems like we still have an issue with "all" mode.

require(igraph)
el <- as.matrix(read.table(text="   1    5
    1    7
    2    5
    2    7
    2   10
    2   13
    2   18
    3    5
    3   10
    3   13
    4    5
    4   10
    5    7
    5   10
    5   13
    5   18
    6    3
    6    5
    6    7
    6   13
    7    5
    8    5
    8   10
    8   18
    9    3
    9    5
    9    7
    9   10
   11    5
   12    5
   12    7
   14    5
   14    7
   14   13
   14   18
   15    5
   15   13
   15   18
   16    5
   16   10
   16   13
   16   18
   17    5",header=FALSE))
g <- graph.edgelist(el)
g
#IGRAPH D--- 18 43 -- 
sapply(graph.neighborhood(g,order=1,mode="all"),ecount)
# [1]  4 10 11  3 43  9 14  5  9 14  1  4 14  8  5  7  1 11
local.scan(graph.us=g,mode="all",k=1)
# [1]  4 10 11  3 46  9 18  5  9 14  1  4 14  8  5  7  1 11

Note the difference for the vertex 5; 46 is even bigger than the ecount of the graph! The mode="in" and mode="out" seem to be ok.

gaborcsardi commented 10 years ago

Indeed. I was trying to squeeze too much functionality in a single function....