DOKK / manpages / debian 12 / libdevel-mat-perl / Devel::MAT::Graph.3pm.en
Devel::MAT::Graph(3pm) User Contributed Perl Documentation Devel::MAT::Graph(3pm)

"Devel::MAT::Graph" - a set of references between related SVs

Instances of this class represent an entire graph of references between related SVs, as a helper method for return values from various Devel::MAT methods, which might be used for some sort of screen layout or other analysis tasks.

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

Constructs a new "Devel::MAT::Graph" instance backed by the given dumpfile (which is only actually used to make the "$node->sv" method work).

   $graph->add_sv( $sv )

Makes the graph aware of the given Devel::MAT::SV. This is not strictly necessary before calling "add_ref" or "add_root", but ensures that "has_sv" will return true immediately after it, and so can be used as a sentinel for recursion control.

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

Adds an edge to the graph, from and to the given SVs, with the given description.

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

Adds a root edge to the graph, at the given SV with the given description.

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

Returns true if the graph has edges or roots for the given SV, or it has at least been given to "add_sv".

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

Returns a "Node" object for the given SV.

   @desc_nodes = $graph->get_root_nodes

Returns an even-sized list of pairs, containing root descriptions and the nodes having those roots, in no particular order.

The values returned by "get_sv_node" respond to the following methods:

   $graph = $node->graph

Returns the containing "Devel::MAT::Graph" instance.

   $addr = $node->addr

Returns the address of the SV represented by this node.

   $sv = $node->sv

Returns the SV object itself, as taken from the dumpfile instance.

   @roots = $node->roots

Returns any root descriptions given (by calls to "$graph->add_root" for the SV at this node.

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

   @edges = $node->edges_out

Returns an even-sized list of any edge descriptions and more "Node" objects given as references (by calls to "$graph->add_ref") from the SV at this node.

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

   $n_edges = $node->edges_out

In scalar context, returns the number of edges that exist; i.e. half the size of the pairlist that would be returned in list context.

   @edges = $node->edges_in

Similar to "edges_out", but returns edges in the opposite direction; i.e. edges of references to this node.

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

   $n_edges = $node->edges_out

In scalar context, returns the number of edges that exist; i.e. half the size of the pairlist that would be returned in list context.

Paul Evans <leonerd@leonerd.org.uk>

2023-03-26 perl v5.36.0