Skip to content

Commit

Permalink
kind of a brain-dead test module
Browse files Browse the repository at this point in the history
  • Loading branch information
waltman committed Jul 20, 2007
1 parent d8286e2 commit 21c871e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions t/1.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# $Id$

use strict;
use Test::More tests => 12;
use Graph;

BEGIN { use_ok('Graph::MaxFlow', qw(max_flow)) }

my $g = new Graph;

$g->add_weighted_edge("s", "v1", 16);
$g->add_weighted_edge("s", "v2", 13);
$g->add_weighted_edge("v1", "v2", 10);
$g->add_weighted_edge("v1", "v3", 12);
$g->add_weighted_edge("v2", "v1", 4);
$g->add_weighted_edge("v2", "v4", 14);
$g->add_weighted_edge("v3", "v2", 9);
$g->add_weighted_edge("v3", "t", 20);
$g->add_weighted_edge("v4", "v3", 7);
$g->add_weighted_edge("v4", "t", 4);

my $flow = max_flow($g, "s", "t");

is($flow, "s-v1,s-v2,v1-v2,v1-v3,v2-v1,v2-v4,v3-t,v3-v2,v4-t,v4-v3");
is($flow->get_edge_weight("v3", "v2"), 0);
is($flow->get_edge_weight("v1", "v3"), 12);
is($flow->get_edge_weight("v3", "t"), 19);
is($flow->get_edge_weight("v4", "t"), 4);
is($flow->get_edge_weight("v1", "v2"), 0);
is($flow->get_edge_weight("v4", "v3"), 7);
is($flow->get_edge_weight("s", "v2"), 11);
is($flow->get_edge_weight("v2", "v1"), 0);
is($flow->get_edge_weight("s", "v1"), 12);
is($flow->get_edge_weight("v2", "v4"), 11);

0 comments on commit 21c871e

Please sign in to comment.