Graph::Maker(3pm)

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.

Releases

Unchanged in 2 releases since Debian 12 (Bookworm).

  1. 12–13

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.

From libgraph-maker-perl 0.02-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.