-
Notifications
You must be signed in to change notification settings - Fork 10
is_planar( ) produces random results #41
Copy link
Copy link
Open
Description
For some planar graphs at least, is_planar( ) randomly yields true or false.
Here is code to reproduce:
#! /usr/bin/perl
use v5.32.0;
use Graph::Undirected;
# use GraphViz2;
my $g = Graph::Undirected->new( );
$g->add_weighted_edge( 'J', 'S', 21);
$g->add_weighted_edge( 'F', 'M', 11);
$g->add_weighted_edge( 'F', 'H', 11);
$g->add_weighted_edge( 'J', 'T', 14);
$g->add_weighted_edge( 'T', 'G', 14);
$g->add_weighted_edge( 'T', 'S', 13);
$g->add_weighted_edge( 'G', 'S', 5);
$g->add_weighted_edge( 'G', 'H', 8);
$g->add_weighted_edge( 'G', 'M', 17);
$g->add_weighted_edge( 'S', 'H', 11);
for my $i(0..9) {
say 'Graph is ', $g->is_planar( ) ? 'planar' : 'not planar';
}
# my $gv = GraphViz2->from_graph($g);
# $gv->run( 'format'=>'png', output_file=>'f.png' );
And here is one result (exact distribution will vary from call to call):
Graph is planar
Graph is planar
Graph is planar
Graph is planar
Graph is planar
Graph is not planar
Graph is planar
Graph is not planar
Graph is not planar
Graph is not planar
In fact, the graph is clearly planar, as can be seen from the enclosed diagram (produced by uncommenting the GraphViz-related lines in the code above).
I have tested on Windows 10, Perl 5.42.0, Graph 0.9735

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels