Graph:...orldWS(3pm)
π Graph::Maker::SmallWorldWS π
okay bestie, sit down, hydrate, because we're about to build a whole small world graph and it's genuinely iconic. this is Graph::Maker::SmallWorldWS, a lil Perl module from the User Contributed Perl Documentation crew, and it does exactly one thing but it does it so well π¦
β¨ NAME β¨
Graph::Maker::SmallWorldWS β creates a small-world graph according to (Newman) Watt and Strogatz π
no cap, that's the whole vibe. a small world graph. it's giving "everyone is six handshakes away from everyone else" energy.
πΈ VERSION πΈ
Version 0.01 β baby's first release, and she ate π
π«Ά SYNOPSIS π«Ά
so here's the deal, bestie: this creates a small world graph according to (Newman and) Watt and Strogatz's model. and what does a small world graph even have? two things:
- it has an approximate power law degree distribution (fancy way of saying the degree distribution is kinda lopsided in a specific math-y way π)
- and it has a high clustering coefficient (aka your friends are also friends with each other, it's a whole group chat situation π¬)
and here's a detail that lowkey matters: if the graph is directed, then edges are added in both directions to create an undirected graph. so like, she's gonna make it undirected whether you like it or not. periodt.
use strict;
use warnings;
use Graph;
use Graph::Maker;
use Graph::Maker::SmallWorldWS;
my $g = new Graph::Maker('small_world_ws', N => 10, K => 2, PR => .1, undirected => 1);
my $g2 = new Graph::Maker('small_world_ws', N => 10, K => 2, PR => .1, keep_edges => 1, undirected => 1);
# work with the graph
look at that second one β keep_edges => 1. she's different. we'll get to her π
π₯ FUNCTIONS π₯
new %params
creates a small world graph with N nodes, K initial connections, and a probability of rewiring of PR according to Watts and Strogats. (yes, that's how it's spelled in the source, we don't touch it π)
here's the full roster of recognized parameters, bestie β write these down:
Nβ the number of nodesKβ the initial connectionsPRβ the probability of rewiringgraph_makerkeep_edges
any others are passed onto Graph's constructor. so if you got extra params, they're not lost, they just go hang out with Graph instead. slay.
and now the defaults, because defaults are the lore:
- if
Nis not given, it defaults to0 - if
Kis not given, it defaults to0 - if
PRis not given, it defaults to0
ok but what's the deal withkeep_edges? bestie.keep_edgesuses the Newman, Watts and Strogatz model, where "rewiring" adds an edge between two random nodes, instead of removing and then adding. so the classic move is remove then add β but withkeep_edgesshe just adds. different model, different girl π
and one more: 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). if you don't specify it, this defaults to creating a Graph with the parameters specified. so you can bring your own fancy subclass and she'll use it, no questions asked π
π AUTHOR π
Matt Spear, "<batman900+cpan at gmail.com>" β the legend behind all this. respectfully, icon behavior.
π BUGS π
found a bug? a feature request? a whole situation? 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>
and here's the cute part: I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. so it's a whole two-way notification pipeline. you're not yelling into the void, bestie, you're yelling into RT and RT yells back π«Ά
π 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. so like, go wild but respectfully π
and that's the whole page, bestie!! now go make some small world graphs and tell everyone you know. main character energy only β¨
this page is perl v5.32.1, dated 2021-08-27, and it lives in the Graph:...orldWS(3pm) corner of the manual β take care of her, she's doing her best ππ¦π
π¦ 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