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 P manhattan units of distance, and
  • Q random long-range connections to nodes determined by d(u, v) ** -alpha (where d is 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 N is not given it defaults to 0.
  • if P is not given it defaults to 1.
  • if Q is not given it defaults to 0.
  • if alpha is not given it defaults to 2 β€” and listen, 2 <= alpha <= 3 allows poly-logarithmic routing using a local greedy algorithm. that range is the moment. πŸ‘‘
  • if cyclic is set then the "edges" of the grid are connected.
  • the vertex attribute pos will be set to an array reference of the nodes d-dimensional position. 🧚
  • 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.

πŸ’« 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 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