igraph-help
[Top][All Lists]
Advanced

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

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


From: Gábor Csárdi
Subject: Re: [igraph] Potential igraph issue: path.length.hist()$unconnected incorrect?
Date: Sun, 25 Jan 2009 10:35:28 +0100

Yep, this is a bug. Thanks for reporting it. The correction is:

--- src/structural_properties.c~        2008-11-07 22:22:30.000000000 +0100
+++ src/structural_properties.c 2009-01-25 10:31:40.000000000 +0100
@@ -364,6 +364,7 @@
     for (i=0; i<ressize; i++) {
       VECTOR(*res)[i] /= 2;
     }
+    *unconnected /= 2;
   }

   igraph_vector_long_destroy(&already_added);

Gabor

On Sun, Jan 25, 2009 at 5:42 AM, Magnus <address@hidden> wrote:
> 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)
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

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