Graph::Maker::Degree(3pm)

Graph::Maker::Degree3pm

Creates a graph from a degree distribution.

Usage

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

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 "Could not build a graph with the requested sequences (seq1), (seq2)" or "seq must be an array reference and be a valid degree sequence".

Acknowledgements

This package owes a lot to NetworkX.

Releases

Unchanged in 2 releases since Debian 12 (Bookworm).

  1. 12–13

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.

From libgraph-maker-perl 0.02-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.