Commit aa4afa57 authored by Leigh Stoller's avatar Leigh Stoller

Put in a limit on the number of loops in SpanningTree(), to avoid

infinite loop when the topology has a disconnect (in the wire table).
Print an error message when we detect that we will not finish.
parent e08f90ba
......@@ -43,6 +43,7 @@ use English;
use Carp;
use Date::Parse;
use Time::Local;
use Data::Dumper;
# Configure variables.
my $TB = "@prefix@";
......@@ -668,6 +669,7 @@ sub SpanningTree($)
my ($edges) = @_;
my %vertices = ();
my %edges = ();
my $maxloops = 1000;
#
# Get the unique set of vertices. Also form a hash of edges we can mark.
......@@ -691,7 +693,8 @@ sub SpanningTree($)
#
# Loop according to Prims algorithm.
#
while (1) {
while ($maxloops) {
$maxloops--;
#
# Get the set of marked vertices;
#
......@@ -730,6 +733,9 @@ sub SpanningTree($)
#print Dumper(\%edges);
#sleep(1);
}
if ($maxloops <= 0) {
print STDERR "*** SpanningTree: aborting infinite loop!\n";
}
#
# Return a new set of *marked* edges.
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment