Graph::Maker::Uniform - Creates a graph distributed randomly over the d-dimensional grid.
Version 0.01
Creates a uniform graph with nodes distributed randomly over dims-dimensional unit cube. A uniform graph distributes nodes randomly (generally uniformally) over a unit cube in some number of dimensions, where nodes are connected iff they are with rad units of distnace of eachother and no nodes are within repel distance of eachother. If the graph is directed then edges are added in both directions to create an undirected graph.
use strict; use warnings; use Graph; use Graph::Maker; use Graph::Maker::Uniform; use Math::Random qw/random_normal/; my (@a, @b); @a = (2); @b = (1,1); $g = new Graph::Maker('uniform', N => 100, radius => 0.1, undirected => 1); @a = (2,3,1,2,1); @b = (2,2,1,3,1); $g2 = new Graph::Maker('uniform', N => 100, rad => 0.15, dims => 3, repel => 0.01, random => sub { random_normal($_[0], 0, 0.5) } ); # make the nodes distributed over the cube with a gaussian (normal) distribution # work with the graph
Creates a uniform graph with N nodes randomly distributed over a dims-dimensional unit cube, where nodes are connected if they are within rad euclidian (L2) units of distance, and no nodes are within repel distance of eachother according to the random distribution. The recognized parameters are N, rad, dims, repel, graph_maker, and random. any others are passed onto Graph's constructor. If N is not given it defaults to 0. if rad is not given it defaults to 0. If dims is not given it defaults to 2. If repel is not given it defaults to 0. if random is not given it defaults to uniform (Math::Random::random_uniform(dims, 0, 1)), if random is given it is passed the number of random numbers that should be returned. The vertex attribute pos will be set to an array reference of the nodes d-dimensional position. If graph_maker is specified it will be called to create the Graph class as desired (for example if you have a subclass of Graph), this defaults to create a Graph with the parameters specified.
random
Matt Spear, <batman900+cpan at gmail.com>
<batman900+cpan at gmail.com>
Please report any bugs or feature requests to bug-graph-maker-uniform 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.
bug-graph-maker-uniform at rt.cpan.org
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.
To install Graph::Maker, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Graph::Maker
CPAN shell
perl -MCPAN -e shell install Graph::Maker
For more information on module installation, please visit the detailed CPAN module installation guide.