View on
MetaCPAN
Matt Spear > Graph-Maker-0.02 > Graph::Maker

Download:
Graph-Maker-0.02.zip

Dependencies

Annotate this POD

CPAN RT

New  5
Open  1
View/Report Bugs
Module Version: 0.02   Source  

NAME ^

Graph::Maker - Create many types of graphs

VERSION ^

Version 0.02

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

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.

SEE ALSO ^

Class::Factory
Graph

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.

ACKNOWLEDGEMENTS ^

This package owes a lot to NetworkX, 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.

syntax highlighting: