Graph:...Regular(3pm)

πŸ’– Graph::Maker::Regular πŸ’–

okay bestie, sit DOWN, because we're about to talk about the cutest little Perl module in the whole CPAN: Graph::Maker::Regular, from the User Contributed Perl Documentation collection, section 3pm (that's the Perl module manuals section, iykyk). It makes k-regular graphs. That's the whole vibe. ✨


πŸ¦‹ VERSION πŸ¦‹

Version 0.01 β€” baby's first release, and she ate. πŸ’…


🌸 SYNOPSIS 🌸

So here's the deal: this thing creates a regular graph with however many nodes you want and a degree you pick. A regular graph means every single node is connected to exactly K other nodes β€” no favorites, no main character nodes, total equality, we love to see it. 🫢

And lowkey important: if the graph is directed, then edges get added in both directions to create an undirected graph. Yes girl, she flips it for you.

use strict;
use warnings;
use Graph;
use Graph::Maker;
use Graph::Maker::Regular;

my $g = new Graph::Maker('regular', N => 10, K => 2, undirected => 1);
# work with the graph

Look at that. Ten nodes, degree two. Iconic.


πŸŽ€ FUNCTIONS πŸŽ€

✨ new %params ✨

Creates a k-regular graph with the number of nodes you asked for. Here's the tea on the recognized parameters, bestie:

  • graph_maker β€” if you specify it, it gets called to create the Graph class as you want (say, if you have a subclass of Graph, periodt πŸ‘‘)
  • N β€” the number of nodes. If you don't give it, it defaults to 0.
  • K β€” the degree. If you don't give it, it also defaults to 0.

Anything else you pass in gets passed on to Graph's constructor. No gatekeeping here.

⚠️ Heads up queen: N*K must be even. That's not a suggestion, that's math. πŸ’€

And 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) β€” otherwise it defaults to creating a Graph with the parameters specified.

If it just cannot make the graph you asked for, it will croak with the message:

Could not form the requested graph...

so dramatic, honestly, and honestly? fair. 😭


πŸ’œ AUTHOR πŸ’œ

Matt Spear, "<batman900+cpan at gmail.com>" β€” thank you for your service king 🫑


πŸ“ BUGS πŸ“

None at the moment... ✨ (manifesting that energy forever tbh)

But fr fr, please report any bugs or feature requests to "bug-graph-maker-regular at rt.cpan.org", or through the web interface at:

<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Graph-Maker>

And one more time for the people in the back: 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.


🌈 ACKNOWLEDGEMENTS 🌈

This package owes a lot to NetworkX. Shoutout to NetworkX, we see you, we appreciate you. πŸ’–


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.


and that's the whole page bestie!! written by the lovely folks behind the User Contributed Perl Documentation, running on perl v5.32.1, dated 2021-08-27 β€” go forth and make regular graphs, you absolute genius πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from