Graph::Maker - Create many types of graphs


Graph-Maker documentation  | view source Contained in the Graph-Maker distribution.

Index


NAME

Top

Graph::Maker - Create many types of graphs

VERSION

Top

Version 0.02

SYNOPSIS

Top

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

Top

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

Top

Class::Factory
Graph

AUTHOR

Top

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

BUGS

Top

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

Top

This package owes a lot to NetworkX, this is something I think is really needed to extend the great Graph module.

COPYRIGHT & LICENSE

Top


Graph-Maker documentation  | view source Contained in the Graph-Maker distribution.