Graph::ChainBuilder - build directed 2-regular cyclic graphs
This object collects data into a set of ordered chains, allowing you to organize e.g. edges AB,CD,AD,CB into the circular sequence AB,BC,CD,DA while keeping track of the directionality of the input data.
my $graph = Graph::ChainBuilder->new; while(whatever) { ... $graph->add($p0, $p1, $data); }
An edge is defined by the strings $p0 and $p1. The $data is whatever you want to associate with an edge.
foreach my $loop ($graph->loops) { foreach my $edge (@$loop) { ... $edge->data; } }
This code will identify multiple independent loops in an arbitrary set of unordered edges, but assumes that all loops are closed and that no stray edges exist. The result is undefined if your input contains duplicate or dangling edges.
my $graph = Graph::ChainBuilder->new;
Adds an edge to the graph. The nodes $p0 and $p1 will be connected (if possible) to the existing loops.
$graph->add($p0, $p1, $data);
Attempting to add an edge with a point which has already been connected will throw an error.
my $e = Graph::ChainBuilder::edge->new($p0, $p1, $rev, $data);
Eric Wilhelm @ <ewilhelm at cpan dot org>
http://scratchcomputing.com/
If you found this module on CPAN, please report any bugs or feature requests through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
If you pulled this development version from my /svn/, please contact me directly.
Copyright (C) 2009 Eric L. Wilhelm, All Rights Reserved.
Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Graph::ChainBuilder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Graph::ChainBuilder
CPAN shell
perl -MCPAN -e shell install Graph::ChainBuilder
For more information on module installation, please visit the detailed CPAN module installation guide.