Graph::Maker(3pm)

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

okay bestie, welcome to Graph::Maker(3pm) β€” the perl manual page that's literally about making graphs. this is a User Contributed Perl Documentation page, so you know it's giving community-made, handcrafted, artisanal ✨


🌸 NAME 🌸

Graph::Maker β€” create many types of graphs. that's it, that's the whole vibe. many. types. graphs. πŸ‘‘


πŸŽ€ VERSION πŸŽ€

Version 0.02 β€” baby numbers, but she's working 🫢


🌈 SYNOPSIS 🌈

so basically this is the base class for Graph::Maker::*. the subclasses extend this class and override the init method, and init gets handed the class plus the parameters. and the whole thing rides on Class::Factory. iykyk πŸ’…

use strict;
use warnings;
use Graph;
use Graph::Maker;
use Graph::Maker::Linear; # or import qw/Graph::Maker/;

my $g = new Graph::Maker('linear', N => 10);
# work with the graph

literally that's all it takes, no cap.


πŸ¦‹ SUBCLASSING πŸ¦‹

okay so the simplest example ever is the linear graph β€” node i is connected to node i+1. that's the whole personality. the implementation can simply be:

package Graph::Maker::Linear;

use strict;
use warnings;
use Carp;
use base qw/Graph::Maker/;
use Graph;

sub init
{
    my ($self, %params) = @_;

    my $N = delete($params{N});

    my $g = new Graph(%params);
    $g->add_path(1..$N);
    return $g;
}

Graph::Maker->add_factory_type( 'linear' => __PACKAGE__ );

1;

now a real implementation should check that N is defined and is valid (the one provided in this package does, she's thorough πŸ’…). and honestly? it is that simple. that's the tea.


πŸ’€ SEE ALSO πŸ’€

  • Class::Factory
  • Graph

πŸ“ AUTHOR πŸ“

Matt Spear, "<batman900+cpan at gmail.com>" β€” shoutout to the author, icon behavior πŸ™ˆ


πŸ’œ BUGS πŸ’œ

None at the moment... ✨ manifesting that energy forever ✨

Please report any bugs or feature requests to "bug-graph-maker 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.

like, mutual notif system? we love a two-way street fr fr 🫢


🌸 ACKNOWLEDGEMENTS 🌸

This package owes a lot to NetworkX <http://networkx.lanl.gov/>, this is something I think is really needed to extend the great Graph module. lowkey iconic of them to say it πŸ’–


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.


bestie reminder: free software, same terms as Perl, don't be weird about it πŸ’…

and that's the page!! this was perl v5.32.1, dated 2021-08-27, and the manual is Graph::Maker(3pm) β€” go forth and make graphs, main character πŸ¦‹βœ¨

πŸ“¦ where this page comes from