igraph-help
[Top][All Lists]
Advanced

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

[igraph] Potential igraph issue: path.length.hist()$unconnected incorrec


From: Magnus
Subject: [igraph] Potential igraph issue: path.length.hist()$unconnected incorrect?
Date: Sat, 24 Jan 2009 23:42:06 -0500
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)

The following is a reproduction of what I suspect is an issue with the
implementation of path.length.hist()$unconnected. For undirected graphs, it
seems to return double what I would expect it to return. One possibility
might be that the estimate for directed graphs is being returned, but
it could be something else of course.

Best,
Magnus

> #######################################################################
> ##     Issue reproduction
> #######################################################################
>
> library(igraph)
> g <- graph( c(0,1, 0,2, 1,2, 2,4), n=5, dir=FALSE )
>
> # Report the histogram. $unconnected is 8 rather than 4 as expected
> path.length.hist(g, FALSE)
$res
[1] 4 2

$unconnected
[1] 8

>
> # This fails. The sum is 14, rather than 10 as it should be
> stopifnot( (5*4/2) == sum(unlist(path.length.hist(g, FALSE))))
Error: (5 * 4/2) == sum(unlist(path.length.hist(g, FALSE))) is not TRUE
>
> # This succeeds, even if it shouldn't. The reason:
> # $unconnected is double what it should be in an undirected graph
> stopifnot( (5*4/2) == sum(path.length.hist(g, FALSE)$res)
+                     + path.length.hist(g, FALSE)$unconnected/2)




reply via email to

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