Subject: | complement keep all vertices |
Date: | Thu, 16 Jun 2016 22:35:25 +1000 |
To: | bug-Graph [...] rt.cpan.org |
From: | Kevin Ryde <user42_kevin [...] yahoo.com.au> |
In Graph 0.9704 on moderately recent debian i386 perl 5.22.1, the
complement() method doesn't keep vertices which have no edges in the
resulting complement graph. I hoped it would, since the docs say "same
vertices" (and since then complement(complement(g))==g).
Sample program below prints "complement 0 vertices 0 edges" where I
hoped "2 vertices 0 edges", retaining the two original vertices even
though in the complement they both now have no edges.
use strict;
use Graph;
my $graph = Graph->new(undirected=>1);
$graph->add_edge(1, 2);
print "graph $graph\n";
$graph = $graph->complement;
print "complement $graph\n";
print " ", scalar($graph->vertices), " vertices ",
scalar($graph->edges)," edges\n",;