Graph:...lWorldK(3pm)
π Graph::Maker::SmallWorldK π
okay so bestie, welcome to the manual page for Graph::Maker::SmallWorldK, living its best life in section 3pm of the User Contributed Perl Documentation. this is where tiny worlds get built and the routing is chef's kiss. π¦
πΈ NAME πΈ
Graph::Maker::SmallWorldK β creates a small world graph using Kleinberg's model in 2-dimensions. no cap, that's the whole job. π
β¨ VERSION β¨
Version 0.01 β baby version, but she's iconic.
π SYNOPSIS π
so the vibe is: this makes a small world graph according to Kleinberg's long-range connection model. in Kleinberg's model, a small world graph is connected to nodes within manhattan (L1) distance P, and it has Q long range contacts. this whole thing gets referred to as K(N, P, Q, alpha), or K*(N, P, Q, alpha) if it wraps-around. β¨
and here's the part that's giving main character energy: Kleinberg's model gives all nodes a position so that routing can be done efficiently using a greedy algorithm. those positions get set in the 'pos' attribute for the vertices. π
also, if the graph is directed, then edges are added in both directions to create an undirected graph. periodt.
use strict;
use warnings;
use Graph;
use Graph::Maker;
use Graph::Maker::SmallWorldK;
my $g = new Graph::Maker('small_world_k', N => 10, P => 2, undirected => 1);
my $g2 = new Graph::Maker('small_world_k', N => 10, P => 2, Q => 1, alpha => 2.1, undirected => 1);
# work with the graph
π₯ FUNCTIONS π₯
π new %params
creates a small world graph with N^2 nodes in a 2-d grid, with:
- connections to nodes within
Pmanhattan units of distance, and Qrandom long-range connections to nodes determined byd(u, v) ** -alpha(wheredis the manhattan distance) according to Kleinberg's model
(and the grid wraps-around if cyclic is specified π)
the recognized parameters are N, P, Q, cyclic, graph_maker, and alpha. any others are passed onto Graph's constructor. π
here's the defaults tea, bestie:
- if
Nis not given it defaults to0. - if
Pis not given it defaults to1. - if
Qis not given it defaults to0. - if
alphais not given it defaults to2β and listen,2 <= alpha <= 3allows poly-logarithmic routing using a local greedy algorithm. that range is the moment. π - if
cyclicis set then the "edges" of the grid are connected. - the vertex attribute
poswill be set to an array reference of the nodes d-dimensional position. π§ - 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 create a Graph with the parameters specified.
π« AUTHOR π«
Matt Spear, "<batman900+cpan at gmail.com>" β shoutout to the author, absolute legend. π«Ά
π BUGS π
please report any bugs or feature requests to "bug-graph-maker-SmallWorldK 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. teamwork makes the dream work fr fr. π
π 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.
okay that's the whole page bestie, you're fully caught up, no skipped sections, we ate that. π
sign-off time: this lil masterpiece is documented for perl v5.32.1, dated 2021-08-27 β so if you ever forget, that's the version and the date right there. stay slay, go build a small world, and remember: alpha between 2 and 3 or it's not the same vibe. π
β¨
π¦ 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