File: dom

package info (click to toggle)
algotutor 0.8.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 576 kB
  • sloc: perl: 2,563; makefile: 41; php: 24; sh: 1
file content (26 lines) | stat: -rw-r--r-- 556 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# vim: syntax=perl

use strict;

# 2-d point domination
sub dom {
    my ($gr, %opts) = @_;
    my (@V, $v, @dom);
    @V = sort { $a->pos()->[0] <=> $b->pos()->[0] }
	values %{ $gr->cget(-vertices) };
    foreach $v (@V) {
	$v->configure(-status=>"focus");
	$gr->cget(-canvas)->set_mark(0);
	while (@dom and $dom[$#dom]->pos()->[1] <= $v->pos()->[1]) {
	    my ($t) = pop @dom;
	    $t->configure(-status=>"discard");
	    $gr->cget(-canvas)->set_mark(0);
	}
	push @dom, $v;
	$v->configure(-status=>"done");
	$gr->cget(-canvas)->set_mark(1);
    }
}

1;