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 N is not given it defaults to 0.
  • If PR is not given it defaults to 0.
  • If PR is 1 or M is bigger than N*(N-2)/2 then it returns a Complete Graph. Every single edge. She ate πŸ‘‘
  • If M is not given it defaults to 0.
  • If PR and M are both nonzero, it ignores M. (sorry M bestie 😭)
  • 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 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 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