logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Graph::Maker - Create many types of graphs

Acknowledgements

       This  package  owes  a  lot  to NetworkX <http://networkx.lanl.gov/>, this is something I think is really
       needed to extend the great Graph module.

Author

       Matt Spear, "<batman900+cpan at gmail.com>"

Bugs

       None at the moment...

       Please  report  any  bugs  or  feature  requests  to "bug-graph-maker at rt.cpan.org", or through the web
       interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Graph-Maker>.  I will be notified, and  then
       you'll automatically be notified of progress on your bug as I make changes.

Name

       Graph::Maker - Create many types of graphs

See Also

       Class::Factory
       Graph

Subclassing

       The simplest example is the linear graph, nodes i is connected to node i+1.  The implimentation can
       simply be:

               package Graph::Maker::Linear;

               use strict;
               use warnings;
               use Carp;
               use base qw/Graph::Maker/;
               use Graph;

               sub init
               {
                       my ($self, %params) = @_;

                       my $N = delete($params{N});

                       my $g = new Graph(%params);
                       $g->add_path(1..$N);
                       return $g;
               }

               Graph::Maker->add_factory_type( 'linear' => __PACKAGE__ );

               1;

       A real implimentation should check that N is defined and is valid (the one provided in this package
       does).  It is that simple.

Synopsis

       Base class for Graph::Maker::*.  Subclasses extend this class and override the init method.  The init
       method is passed the class and the parameters.  This uses Class::Factory.

               use strict;
               use warnings;
               use Graph;
               use Graph::Maker;
               use Graph::Maker::Linear; # or import qw/Graph::Maker/;

               my $g = new Graph::Maker('linear', N => 10);
               # work with the graph

Version

       Version 0.02

See Also