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::SmallWorldK - Creates a small world graph using Kleinberg's model in 2-dimensions

Author

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

Bugs

       Please report any bugs or feature requests to "bug-graph-maker-SmallWorldK 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 small world graph with N^2 nodes in a 2-d grid, with connections to nodes within P manhattan
       units of distance, and Q random long-range connections to nodes determined by d(u, v) ** -alpha (where d
       is the manhattan distance) according to Kleinberg's model (the grid wraps-around if cyclic is specified).
       The recognized parameters are N, P, Q, cyclic, graph_maker,  and alpha any others are passed onto Graph's
       constructor.  If N is not given it defaults to 0.  If P is not given it defaults to 1.  If Q is not given
       it defaults to 0.  If alpha is not given it defaults to 2 (2 <= alpha <= 3 allows poly-logarithmic
       routing using a local greedy algorithm).  If cyclic is set then the "edges" of the grid are connected.
       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.

Name

       Graph::Maker::SmallWorldK - Creates a small world graph using Kleinberg's model in 2-dimensions

Synopsis

       Creates a small world graph according to Kleinberg's long-range connection model.  In Kleinberg's model a
       small world graph is connected to nodes within manhattan (L1) distance P and has Q long range contacts
       referred to as K(N, P, Q, alpha) or K*(N, P, Q, alpha) (if it wraps-around).  In addition Kleinberg's
       model gives all nodes a position so that routing can be done efficiently using a greedy algorithm, these
       positions are set in the 'pos' attribute for the vertices.  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::SmallWorldK;

               my $g = new Graph::Maker('small_world_k', N => 10, P => 2, undirected => 1);
               my $g2 = new Graph::Maker('small_world_k', N => 10, P => 2, Q => 1, alpha => 2.1, undirected => 1);
               # work with the graph

Version

       Version 0.01

See Also