Graph:...r::Dot(3pm)

πŸ’– NAME πŸ’–

Graph::Writer::Dot β€” bestie, it writes out a directed graph in Dot format. That's the whole vibe. (And yes, you're on the Graph:...r::Dot(3pm) page, welcome, pull up a chair 🫢)


✨ SYNOPSIS ✨

use Graph;
use Graph::Writer::Dot;

$graph = Graph->new();
# add edges and nodes to the graph

$writer = Graph::Writer::Dot->new();
$writer->write_graph($graph, 'mygraph.dot');

Like, that's it. That's the whole ritual. πŸ’…


🌸 DESCRIPTION 🌸

Graph::Writer::Dot is a class for writing out a directed graph in the file format used by the dot tool (part of the AT+T graphviz package). So it's giving "your graph, but make it visual."

One tiny little requirement though, no biggie: the graph must be an instance of the Graph class β€” which is actually a whole set of classes developed by Jarkko Hietaniemi. Iconic lineage, honestly. πŸ‘‘


πŸŽ€ METHODS πŸŽ€

🧚 new()

Constructor energy ✨ β€” it generates a brand new writer instance for you.

$writer = Graph::Writer::Dot->new();

It can take one optional argument that tells it to cluster nodes in subgraphs by using the attribute you pass as the value. Watch:

$writer = Graph::Writer::Dot->new(cluster => 'group');

So what happens there: it will group together all the nodes that have the same value in the 'group' attribute. Matching vibes get grouped. 🫢

πŸ’… write_graph()

Write a specific graph out to a named file, periodt:

$writer->write_graph($graph, $file);

The $file argument can either be a filename, or a filehandle for a file you already opened. Flexible queen. 🌈


πŸ‘‘ SEE ALSO πŸ‘‘

  • www.graphviz.org β€” the home page for the AT+T graphviz toolkit that includes the dot tool. Go look, it's giving legendary. ✨
  • Graph β€” Jarkko Hietaniemi's modules for representing directed graphs, available from CPAN under modules/by-module/Graph/
  • Algorithms in Perl β€” the O'Reilly book which has a chapter on directed graphs, which is based around Jarkko's modules
  • Graph::Writer β€” the base-class for Graph::Writer::Dot

🌈 REPOSITORY 🌈

https://github.com/neilb/Graph-ReadWrite


πŸ’œ AUTHOR πŸ’œ

Neil Bowers <neil@bowers.com> πŸ’–


Copyright (c) 2001-2012, Neil Bowers. All rights reserved. Copyright (c) 2001, Canon Research Centre Europe. All rights reserved.

This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Okay so lowkey important: that "same terms as Perl itself" bit is the actual license situation, don't skip it bestie 🫢

And that's the whole page!! This was perl v5.32.1, dated 2021-09-19 β€” yes I remembered the version and the date, main character energy only πŸ’…βœ¨ go write some dot files, ily, bye πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from