table of contents
Devel::MAT::Graph(3pm) | User Contributed Perl Documentation | Devel::MAT::Graph(3pm) |
NAME¶
"Devel::MAT::Graph" - a set of references between related SVs
DESCRIPTION¶
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.
CONSTRUCTOR¶
new¶
$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).
MUTATION METHODS¶
add_sv¶
$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.
add_ref¶
$graph->add_ref( $from_sv, $to_sv, $desc );
Adds an edge to the graph, from and to the given SVs, with the given description.
add_root¶
$graph->add_root( $from_sv, $desc );
Adds a root edge to the graph, at the given SV with the given description.
QUERY METHODS¶
has_sv¶
$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".
get_sv_node¶
$node = $graph->get_sv_node( $sv );
Returns a "Node" object for the given SV.
get_root_nodes¶
@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.
NODE OBJECTS¶
The values returned by "get_sv_node" respond to the following methods:
graph¶
$graph = $node->graph;
Returns the containing "Devel::MAT::Graph" instance.
addr¶
$addr = $node->addr;
Returns the address of the SV represented by this node.
sv¶
$sv = $node->sv;
Returns the SV object itself, as taken from the dumpfile instance.
roots¶
@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_out¶
@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;
edges_out (scalar)¶
$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_in¶
@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;
edges_in (scalar)¶
$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.
AUTHOR¶
Paul Evans <leonerd@leonerd.org.uk>
2024-10-15 | perl v5.40.0 |