Graph:...Random(3pm)
β¨ NAME β¨
Graph::Maker::Random β bestie, this makes you a random graph π (using Erdos Renyi, or with a specified number of edges, whichever vibe you're feeling)
πΈ VERSION πΈ
Version 0.01 β she's an OG, ok?? π
π¦ SYNOPSIS π¦
So here's the tea: this creates a random graph with N nodes and exactly M edges, OR it connects random edges with probability PR. Two whole modes, one icon.
A random graph has N nodes and M random edges, OR β plot twist β for every pair of nodes it adds an edge with probability PR (that's the Erdos-Renyi graph, iykyk). And if the graph is directed? Edges get added in both directions to create an undirected graph. The way it just does that π
use strict;
use warnings;
use Graph;
use Graph::Maker;
use Graph::Maker::Random;
my $g = new Graph::Maker('random', N => 10, M => 2, undirected => 1);
my $g = new Graph::Maker('random', N => 100, PR => .01, undirected => 1);
# work with the graph
π FUNCTIONS π
π new %params
Creates a random graph with N nodes, either connecting edges with the given probability (PR) or with the specified number of edges (M). Pick your fighter β¨
The recognized parameters are graph_maker, N, M, and PR β and any others get passed straight onto Graph's constructor, no questions asked π«Ά
Okay now the important deets, fr fr:
- If
Nis not given it defaults to0. - If
PRis not given it defaults to0. - If
PRis1orMis bigger thanN*(N-2)/2then it returns a Complete Graph. Every single edge. She ate π - If
Mis not given it defaults to0. - If
PRandMare both nonzero, it ignoresM. (sorry M bestie π) - If
graph_makeris specified it will be called to create the Graph class as desired (for example if you have a subclass of Graph). This defaults to creating a Graph with the parameters specified.
β AUTHOR β
Matt Spear, "<batman900+cpan at gmail.com>" β the mastermind behind this whole operation ππ
π BUGS π
Found a bug? A feature request that's been living rent-free in your head? Please report it to "bug-graph-maker-random 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. Group chat energy, but for bugs π§β¨
π COPYRIGHT & LICENSE π
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. Periodt π
Ok that's the whole page bestie, go forth and generate some graphs πΈ
Sign-off time: this was written against perl v5.32.1, dated 2021-08-27, and it lives in the User Contributed Perl Documentation collection as Graph::Maker::Random(3pm) β slay, go read it again if you forgot anything π
π¦ where this page comes from
- debian bookworm: libgraph-maker-perl 0.02-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libgraph-maker-perl 0.02-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libgraph-maker-perl 0.02-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libgraph-maker-perl 0.02-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgraph-maker-perl 0.02-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgraph-maker-perl 0.02-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms