1Graph::TransitiveClosurUes(e3r)Contributed Perl DocumentGartaipohn::TransitiveClosure(3)
2
3
4
6 Graph::TransitiveClosure - create and query transitive closure of graph
7
9 use Graph::TransitiveClosure;
10 use Graph::Directed; # or Undirected
11
12 my $g = Graph::Directed->new;
13 $g->add_...(); # build $g
14
15 # Compute the transitive closure graph.
16 my $tcg = Graph::TransitiveClosure->new($g);
17 $tcg->is_reachable($u, $v) # Identical to $tcg->has_edge($u, $v)
18
19 # Being reflexive is the default, meaning that null transitions
20 # (transitions from a vertex to the same vertex) are included.
21 my $tcg = Graph::TransitiveClosure->new($g, reflexive => 1);
22 my $tcg = Graph::TransitiveClosure->new($g, reflexive => 0);
23
24 # is_reachable(u, v) is always reflexive.
25 $tcg->is_reachable($u, $v)
26
27 # You can check any graph for transitivity.
28 $g->is_transitive()
29
30 my $tcg = Graph::TransitiveClosure->new($g, path_length => 1);
31 $tcg->path_length($u, $v)
32
33 # path_vertices is on by default so this is a no-op.
34 my $tcg = Graph::TransitiveClosure->new($g, path_vertices => 1);
35 $tcg->path_vertices($u, $v)
36
37 # see how many paths exist from $u to $v
38 my $tcg = Graph::TransitiveClosure->new($g, path_count => 1);
39 $tcg->path_length($u, $v)
40
41 # Both path_length and path_vertices.
42 my $tcg = Graph::TransitiveClosure->new($g, path => 1);
43 $tcg->path_vertices($u, $v)
44 $tcg->length($u, $v)
45
46 my $tcg = Graph::TransitiveClosure->new($g, attribute_name => 'length');
47 $tcg->path_length($u, $v)
48
50 You can use "Graph::TransitiveClosure" to compute the transitive
51 closure graph of a graph and optionally also the minimum paths (lengths
52 and vertices) between vertices, and after that query the transitiveness
53 between vertices by using the is_reachable() and is_transitive()
54 methods, and the paths by using the path_length() and path_vertices()
55 methods.
56
57 For further documentation, see the Graph::TransitiveClosure::Matrix.
58
59 Class Methods
60 new($g, %opt)
61 Construct a new transitive closure object. Note that strictly
62 speaking the returned object is not a graph; it is a graph plus
63 other stuff. But you should be able to use it as a graph plus a
64 couple of methods inherited from the
65 Graph::TransitiveClosure::Matrix class.
66
67 Object Methods
68 These are only the methods 'native' to the class: see
69 Graph::TransitiveClosure::Matrix for more.
70
71 is_transitive($g)
72 Return true if the Graph $g is transitive.
73
74 transitive_closure_matrix
75 Return the transitive closure matrix of the transitive closure
76 object.
77
78
79
80perl v5.38.0 2023-07-25 Graph::TransitiveClosure(3)