Graph::Maker3pm
Create many types of graphs
Usage
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
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.
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.
Copyright & license
Copyright 2008 Matt Spear, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Releases
Unchanged in 2 releases since Debian 12 (Bookworm).