Devel:...::Graph(3pm)

πŸ’– Devel::MAT::Graph πŸ’–

okay bestie, listen β€” this is Devel::MAT::Graph, out of the User Contributed Perl Documentation corner of the perl world. The manual page itself calls it Devel:...::Graph(3pm) (yes the name is abbreviated like that, don't come for me, it's literally how it's printed). It's pronounced "a set of references between related SVs" and it's basically the group chat of your SVs: who knows who, who points at who, who's a root. ✨


🌸 NAME 🌸

Devel::MAT::Graph β€” a set of references between related SVs πŸ¦‹


πŸ““ DESCRIPTION πŸ““

An instance of this class is the whole entire friend group: an entire graph of references between related SVs, all in one object. It exists as a helper for the return values of various Devel::MAT methods, bestie β€” think of it as the thing you hand off when you wanna do some kind of screen layout, or literally any other analysis task that needs the vibes of "what points to what". πŸ’…


πŸ‘‘ CONSTRUCTOR πŸ‘‘

✨ new ✨

$graph = Devel::MAT::Graph->new( $dumpfile );

Makes you a brand new Devel::MAT::Graph instance, backed by the dumpfile you pass in. Quick heads up though: that dumpfile is only actually used so that the $node->sv method works. That's it. That's its whole job. Lowkey iconic that it gets a whole constructor slot for that. πŸŽ€


πŸ› οΈ MUTATION METHODS πŸ› οΈ

these are the ones that change the graph. be normal about them.

πŸ’« add_sv πŸ’«

$graph->add_sv( $sv );

Introduces the graph to the given Devel::MAT::SV. Now, technically this is not strictly necessary before you call add_ref or add_root β€” but it does make sure that has_sv returns true immediately afterwards, which means you can use it as a sentinel for recursion control. fr fr, that's the actual reason it exists. 🧚

πŸ”— add_ref πŸ”—

$graph->add_ref( $from_sv, $to_sv, $desc );

Adds an edge to the graph, going from and to the given SVs, with the given description. That's the whole thing. Edge secured. ✨

🌱 add_root 🌱

$graph->add_root( $from_sv, $desc );

Adds a root edge to the graph, sitting at the given SV, with the given description. πŸ‘‘


πŸ” QUERY METHODS πŸ”

no mutation, just questions. slay.

❓ has_sv ❓

$bool = $graph->has_sv( $sv );

Returns true if the graph has edges or roots for the given SV β€” or if it's at least been handed to add_sv at some point. Either way: it counts. πŸ’œ

🧭 get_sv_node 🧭

$node = $graph->get_sv_node( $sv );

Hands you back a Node object for the given SV. Cute. ✨

🌳 get_root_nodes 🌳

@desc_nodes = $graph->get_root_nodes;

Returns an even-sized list of pairs β€” root descriptions paired with the nodes that have those roots β€” in no particular order. Do not assume an order, bestie. It does not owe you one. πŸ™ˆ


πŸ¦‹ NODE OBJECTS πŸ¦‹

The values that get_sv_node gives you? They respond to all of these:

🌈 graph 🌈

$graph = $node->graph;

Returns the containing Devel::MAT::Graph instance. It knows its family. 🫢

πŸ“ addr πŸ“

$addr = $node->addr;

Returns the address of the SV that this node is representing. πŸ“¬

🎁 sv 🎁

$sv = $node->sv;

Returns the SV object itself, exactly as taken from the dumpfile instance. (This is the one that makes the dumpfile in the constructor matter, iykyk.) ⭐

🌱 roots 🌱

@roots = $node->roots;

Returns any root descriptions that were given β€” by calls to $graph->add_root β€” for the SV sitting at this node.

$graph->add_root( $sv, $desc );

( $desc, ... ) = $graph->get_sv_node( $sv )->roots;

➑️ edges_out ➑️

@edges = $node->edges_out;

Returns an even-sized list of any edge descriptions plus the further Node objects, for the references going out from the SV at this node (i.e. the ones made by calls to $graph->add_ref).

$graph->add_ref( $from_sv, $to_sv, $desc );

( $desc, $to_edge, ... ) = $graph->get_sv_node( $from_sv )->edges_out;

➑️ edges_out (scalar) ➑️

$n_edges = $node->edges_out;

In scalar context it gives you the number of edges that exist β€” which is to say, half the size of the pairlist you'd get back in list context. Math is math. πŸ’€

⬅️ edges_in ⬅️

@edges = $node->edges_in;

Same energy as edges_out, except it returns edges in the opposite direction β€” so, the edges of references pointing to this node.

$graph->add_ref( $from_sv, $to_sv, $desc );

( $desc, $from_edge, ... ) = $graph->get_sv_node( $to_sv )->edges_in;

⬅️ edges_in (scalar) ⬅️

$n_edges = $node->edges_out;

In scalar context it returns the number of edges that exist β€” i.e. half the size of the pairlist that would come back in list context.

⚠️ okay so real talk: that synopsis line up there literally says $node->edges_out in the original page. I am copying it character for character because that is the rule, but bestie... πŸ‘€ just clock it.

✍️ AUTHOR ✍️

Paul Evans <leonerd@leonerd.org.uk> πŸ’–


and that's the whole page, periodt. 🌟 this ran under perl v5.42.3, dated 2026-08-21, and it's filed under that Devel:...::Graph(3pm) manual name β€” go forth and graph your SVs, bestie, you're gonna eat πŸ“πŸ’…

πŸ“¦ where this page comes from