Graph:...losure(3pm)

✨ Graph::TransitiveClosure πŸ’…

okay bestie, so this page is the manual for Graph::TransitiveClosure, a Perl module from the User Contributed Perl Documentation fam, and honestly? it's giving "I can see the whole graph from here" energy πŸ¦‹


🌸 NAME 🌸

Graph::TransitiveClosure β€” create and query transitive closure of graph

✨ SYNOPSIS ✨

no cap, just look at this:

use Graph::TransitiveClosure;
use Graph::Directed; # or Undirected

my $g  = Graph::Directed->new;
$g->add_...(); # build $g

# Compute the transitive closure graph.
my $tcg = Graph::TransitiveClosure->new($g);
$tcg->is_reachable($u, $v) # Identical to $tcg->has_edge($u, $v)

# Being reflexive is the default, meaning that null transitions
# (transitions from a vertex to the same vertex) are included.
my $tcg = Graph::TransitiveClosure->new($g, reflexive => 1);
my $tcg = Graph::TransitiveClosure->new($g, reflexive => 0);

# is_reachable(u, v) is always reflexive.
$tcg->is_reachable($u, $v)

# You can check any graph for transitivity.
$g->is_transitive()

my $tcg = Graph::TransitiveClosure->new($g, path_length => 1);
$tcg->path_length($u, $v)

# path_vertices is on by default so this is a no-op.
my $tcg = Graph::TransitiveClosure->new($g, path_vertices => 1);
$tcg->path_vertices($u, $v)

# see how many paths exist from $u to $v
my $tcg = Graph::TransitiveClosure->new($g, path_count => 1);
$tcg->path_length($u, $v)

# Both path_length and path_vertices.
my $tcg = Graph::TransitiveClosure->new($g, path => 1);
$tcg->path_vertices($u, $v)
$tcg->length($u, $v)

my $tcg = Graph::TransitiveClosure->new($g, attribute_name => 'length');
$tcg->path_length($u, $v)

πŸ’– DESCRIPTION πŸ’–

so here's the tea, bestie 🫢 you can use Graph::TransitiveClosure to compute the transitive closure graph of a graph, and optionally also the minimum paths (both lengths and vertices) between vertices. and then β€” the main character moment β€” you can query the transitiveness between vertices with the is_reachable() and is_transitive() methods, and the paths with path_length() and path_vertices(). periodt. πŸ‘‘

for further documentation, see the Graph::TransitiveClosure::Matrix. iykyk.


πŸ‘‘ Class Methods πŸ‘‘

  • new($g, %opt) β€” Construct a new transitive closure object. and like, lowkey important: strictly speaking the returned object is not a graph β€” it's a graph plus other stuff. but fr fr, you should be able to use it as a graph plus a couple of methods inherited from the Graph::TransitiveClosure::Matrix class. slay. ✨

πŸ¦‹ Object Methods πŸ¦‹

these are only the methods that are 'native' to the class β€” see Graph::TransitiveClosure::Matrix for more. don't @ me.

  • is_transitive($g) β€” Return true if the Graph $g is transitive. simple as that, no notes. πŸ’…
  • transitive_closure_matrix β€” Return the transitive closure matrix of the transitive closure object. it's giving matrix reveal moment πŸŽ€

and that's the whole page, bestie!! no crumbs left behind πŸ’œ

this lil icon of a doc came to you via perl v5.40.1, dated 2025-03-28 β€” so if you're reading this, know that the vibes are timestamped and officially archived. mwah πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from