---
name: "Devel::MAT::Graph"
section: "3pm"
platform: "linux"
package: "libdevel-mat-perl"
version: "0.53-1+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Devel::MAT::Graph"
---

# Devel::MAT::Graph(3pm)

a set of references between related SVs

## 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\>
