logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Graph::Maker::Uniform - Creates a graph distributed randomly over the d-dimensional grid.

Author

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

Bugs

       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.

Functions

new%params
       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::Free::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

Name

       Graph::Maker::Uniform - Creates a graph distributed randomly over the d-dimensional grid.

Synopsis

       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::Free 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

Version

       Version 0.01

See Also