Graph::Maker - Create many types of graphs


Graph-Maker documentation Contained in the Graph-Maker distribution.

Index


Code 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 Contained in the Graph-Maker distribution.

package Graph::Maker;

use strict;
use warnings;
use base qw/Class::Factory/;

our $VERSION = '0.02';

#Graph::Maker->add_factory_type('balanced_tree' => 'Graph::Maker::BalancedTree');
#Graph::Maker->add_factory_type('barbell' => 'Graph::Maker::Barbell' );
#Graph::Maker->add_factory_type('bipartite' => 'Graph::Maker::Bipartite' );
#Graph::Maker->add_factory_type('circular_ladder' => 'Graph::Maker::CircularLadder' );
#Graph::Maker->add_factory_type('complete' => 'Graph::Maker::Complete' );
#Graph::Maker->add_factory_type('complete_bipartite' => 'Graph::Maker::CompleteBipartite' );
#Graph::Maker->add_factory_type('cycle' => 'Graph::Maker::Cycle' );
#Graph::Maker->add_factory_type('degree' => 'Graph::Maker::Degree' );
#Graph::Maker->add_factory_type('disconnected' => 'Graph::Maker::Disconnected' );
#Graph::Maker->add_factory_type('disk' => 'Graph::Maker::Disk' );
#Graph::Maker->add_factory_type('empty' => 'Graph::Maker::Empty' );
#Graph::Maker->add_factory_type('grid' => 'Graph::Maker::Grid' );
#Graph::Maker->add_factory_type('hypercube' => 'Graph::Maker::HyperCube' );
#Graph::Maker->add_factory_type('ladder' => 'Graph::Maker::Ladder' );
#Graph::Maker->add_factory_type('linear' => 'Graph::Maker::Linear' );
#Graph::Maker->add_factory_type('lollipop' => 'Graph::Maker::Lollipop' );
#Graph::Maker->add_factory_type('random' => 'Graph::Maker::Random' );
#Graph::Maker->add_factory_type('regular' => 'Graph::Maker::Regular' );
#Graph::Maker->add_factory_type('small_world_ba' => 'Graph::Maker::SmallWorldBA' );
#Graph::Maker->add_factory_type('small_world_hk' => 'Graph::Maker::SmallWorldHK' );
#Graph::Maker->add_factory_type('small_world_k' => 'Graph::Maker::SmallWorkdK' );
#Graph::Maker->add_factory_type('small_world_ws' => 'Graph::Maker::SmallWorkdWS' );
#Graph::Maker->add_factory_type('star' => 'Graph::Maker::Star' );
#Graph::Maker->add_factory_type('uniform' => 'Graph::Maker::Uniform' );
#Graph::Maker->add_factory_type('wheel' => 'Graph::Maker::Wheel' );
#Graph::Maker->add_factory_type('linear' => 'Graph::Maker::Linear' );

1;

__DATA__