#!/usr/bin/env perl
use strict;
use warnings;

use Graph::Weighted;
my $gw = Graph::Weighted->new();
$gw->populate(
  [ [ 0, 1, 2, 0, 0 ], # Vertex 0 with 2 edges of weight 3
    [ 1, 0, 3, 0, 0 ], #    "   1      2 "               4
    [ 2, 3, 0, 0, 0 ], #    "   2      2 "               5
    [ 0, 0, 1, 0, 0 ], #    "   3      1 "               1
    [ 0, 0, 0, 0, 0 ], #    "   4      0 "               0
  ]
);
for my $vertex (sort { $a <=> $b } $gw->vertices) {
    warn sprintf "vertex: %s weight=%.2f\n",
        $vertex, $gw->get_cost($vertex);
    for my $neighbor (sort { $a <=> $b } $gw->neighbors($vertex)) {
        warn sprintf "\tedge to: %s weight=%.2f\n",
            $neighbor, $gw->get_cost([$vertex, $neighbor]);
    }
}
