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 automatically always on so this is a no-op.
34 my $tcg = Graph::TransitiveClosure->new($g, path_vertices => 1);
35 $tcg->path_vertices($u, $v)
36
37 # Both path_length and path_vertices.
38 my $tcg = Graph::TransitiveClosure->new($g, path => 1);
39 $tcg->path_vertices($u, $v)
40 $tcg->length($u, $v)
41
42 my $tcg = Graph::TransitiveClosure->new($g, attribute_name => 'length');
43 $tcg->path_length($u, $v)
44
46 You can use "Graph::TransitiveClosure" to compute the transitive
47 closure graph of a graph and optionally also the minimum paths (lengths
48 and vertices) between vertices, and after that query the transitiveness
49 between vertices by using the "is_reachable()" and "is_transitive()"
50 methods, and the paths by using the "path_length()" and
51 "path_vertices()" methods.
52
53 For further documentation, see the Graph::TransitiveClosure::Matrix.
54
55 Class Methods
56 new($g, %opt)
57 Construct a new transitive closure object. Note that strictly
58 speaking the returned object is not a graph; it is a graph plus
59 other stuff. But you should be able to use it as a graph plus a
60 couple of methods inherited from the
61 Graph::TransitiveClosure::Matrix class.
62
63 Object Methods
64 These are only the methods 'native' to the class: see
65 Graph::TransitiveClosure::Matrix for more.
66
67 is_transitive($g)
68 Return true if the Graph $g is transitive.
69
70 transitive_closure_matrix
71 Return the transitive closure matrix of the transitive closure
72 object.
73
74 INTERNALS
75 The transitive closure matrix is stored as an attribute of the graph
76 called "_tcm", and any methods not found in the graph class are
77 searched in the transitive closure matrix class.
78
79
80
81perl v5.28.1 2015-09-22 Graph::TransitiveClosure(3)