Graph::Weighted::Capacity - A capacity graph implementation


NAME

Graph::Weighted::Capacity - A capacity graph implementation


SYNOPSIS

  use Graph::Weighted::Capacity;
  $g = Graph::Weighted::Capacity->new(
      data => [
          [ 0, 1, 2, 0, 0 ],  # A vertex with two edges.
          [ 1, 0, 3, 0, 0 ],  # "
          [ 2, 3, 0, 0, 0 ],  # "
          [ 0, 0, 1, 0, 0 ],  # A vertex with one edge.
          [ 0, 0, 0, 0, 0 ]   # A vertex with no edges.
      ]
  );
  $g = Graph::Weighted::Capacity->new(
      data => {
          capacity => {
              a => { b => 1, c => 2 },  # A vertex with two edges.
              b => { a => 1, c => 3 },  # "
              c => { a => 2, b => 3 },  # "
              d => { c => 1 },          # A vertex with one edge.
              e => {}                   # A vertex with no edges.
          },
          weight => [
              [ 1, 2, 3 ],
              [ 4, 5, 6 ],
              [ 7, 8, 9 ]
          ]
      }
  );
  $g = Graph::Weighted::Capacity->new(
      data => $Math_Matrix_object,
      retrieve_as => 'ARRAY',
  );
  $data = $g->capacity_data;
  $c = $g->graph_capacity;
  $c = $g->vertex_capacity($v1);
  $c = $g->vertex_capacity($v1, $c + 1);
  $c = $g->edge_capacity($v1, $v2);
  $c = $g->edge_capacity($v1, $v2, $c + 1);
  $vertices = $g->largest_vertices;
  $vertices = $g->smallest_vertices;
  $c = $g->max_capacity;  # Capacity of the largest vertices.
  $c = $g->min_capacity;  # Capacity of the smallest vertices.
  # Call the capacity methods of the inherited Graph module.
  $x = $g->Flow_Ford_Fulkerson($state);
  $x = $g->Flow_Edmonds_Karp($source, $sink);


DESCRIPTION

A Graph::Weighted::Capacity object represents a subclass of Graph::Weighted with capacity attributes that are taken from a two dimensional matrix of numerical values.

This module can use a standard array or hash reference for data. It can also load the matrix portions of Math::Matrix, Math::MatrixReal, and Math::MatrixBool objects.

Initially, the capacities of the vertices are set to the sum of their outgoing edge capacities. This is mutable, however, and can be reset to any value desired, after initialization, with the vertex_capacity and edge_capacity methods.

This module is an extension of a more generic module that can handle multiple attributes - not just capacity and weight. Please see the Graph::Weighted documentation.


PUBLIC METHODS


PRIVATE METHODS


SEE ALSO

the Graph::Base manpage

the Graph::Weighted manpage


AUTHOR

Gene Boggs <gene@cpan.org>


COPYRIGHT AND LICENSE

Copyright 2003 by Gene Boggs

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

 Graph::Weighted::Capacity - A capacity graph implementation