| Graph::Weighted::Capacity - A capacity graph implementation |
Graph::Weighted::Capacity - A capacity graph implementation
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);
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.
Flag to invoke verbose mode while processing. Defaults to zero.
Flag to add edges between vertices with a capacity of zero. Defaults to zero.
Two dimensional hash (HoH), (NxN) array, or object reference to use for vertex and edge capacities.
Math::Matrix, Math::MatrixReal, and Math::MatrixBool objects
can also be loaded.
Flag to tell the capacity_data method to output as a hash or array
reference. Defaults to HASH.
If this object attribute is set to ARRAY, the zero_edges
attribute is automatically turned on.
Turn the given two dimensional hash, (NxN) array, or object reference
into the vertices and edges of a Graph::Directed object.
Math::Matrix, Math::MatrixReal, and Math::MatrixBool objects
can also be loaded.
Return a two dimensional representation of the vertices and all their capacity edges.
The representation can be either a hash or array reference, depending
on the retrieve_as object attribute setting.
Get the total capacity of the graph, which is the sum of all the vertex capacities.
Return the capacity of a vertex.
(The vertices are just the keys of the data, not some glorified object, by the way.)
If a second argument is provided, the vertex capacity is set to that value and is distributed evenly to the vertex's outgoing edges, and the total capacity of the graph is adjusted accordingly.
Return the capacity of an edge between the two given vertices.
If a third argument is provided, the capacity it represents is used to replace the capacity of the edge between the vertex (first argument) and it's successor (second argument). Finally, the capacity of the vertex and the total capacity of the graph are adjusted accordingly.
Return an array reference of vertices with the most capacity.
Return an array reference of vertices with the least capacity.
Return the capacity of the largest vertices.
Return the capacity of the smallest vertices.
Print the contents of the argument array with a newline appended.
Gene Boggs <gene@cpan.org>
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 |