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::Degree - Creates a graph from a degree distribution.

Acknowledgements

       This package owes a lot to NetworkX.

Bugs

       Please report any bugs or feature requests to "bug-graph-maker-smallworldws at rt.cpan.org", or through
       the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Graph-Maker>.  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.

Functions

new%params
       Creates a graph with the given degree distribution (seq) with N nodes. The recognized parameters are
       graph_maker, N and seq, and any others that are passed onto Graph's constructor. If N is not given, it is
       assumed to be the length of seq. If N is greater than seq, then the remaining values are assumed to be
       zero. If strict is set, then uses a deterministic algorithm to ensure (if possible) the correct degree
       distribution; otherwise it is not guaranteed that it will have the exact distribution specified. If
       graph_maker is specified, it will be called to create the Graph class (for example if you have a subclass
       of Graph). Will croak if strict is turned on and it is unable to create a graph with the given degree
       sequences with either the message "Couldnotbuildagraphwiththerequestedsequences(seq1),(seq2)"
       or "seqmustbeanarrayreferenceandbeavaliddegreesequence".

Name

       Graph::Maker::Degree - Creates a graph from a degree distribution.

Synopsis

       Creates a graph with the given degree distribution. If the graph is directed, then edges sare added in
       both directions to create an undirected graph.

               use strict;
               use warnings;
               use Graph;
               use Graph::Maker;
               use Graph::Maker::Degree;

               my (@a, @b);
               @a = (2,1,1);
               $g = new Graph::Maker('degree', N => 5, seq => [@a], undirected => 1);
               @a = (2,3,1,1,1);
               $g = new Graph::Maker('degree', seq => [@a], strict => 1, undirected => 1);
               ok(&checkgraph());
               # a 3-regular graph
               @a = (3,3,3,3,3,3,3,3,3,3,3,3);
               $g = new Graph::Maker('degree', seq => [@a], strict => 1, undirected => 1);
               # This will croak.
               eval {
               @a = (2,2);
               $g = new Graph::Maker('degree', N => 5, seq => [@a], undirected => 1);
               };
               warn $@;
               # work with the graph

Version

       Version 0.01

See Also