1Graph::BitMatrix(3) User Contributed Perl Documentation Graph::BitMatrix(3)
2
3
4
6 Graph::BitMatrix - create and manipulate a V x V bit matrix of graph G
7
9 use Graph::BitMatrix;
10 use Graph::Directed;
11 my $g = Graph::Directed->new;
12 $g->add_...(); # build $g
13 my $m = Graph::BitMatrix->new($g, %opt);
14 $m->get($u, $v)
15 $m->set($u, $v)
16 $m->unset($u, $v)
17 $m->get_row($u, $v1, $v2, ..., $vn)
18 $m->set_row($u, $v1, $v2, ..., $vn)
19 $m->unset_row($u, $v1, $v2, ..., $vn)
20 $a->vertices()
21
23 This class enables creating bit matrices that compactly describe the
24 connected of the graphs.
25
26 Class Methods
27 new($g)
28 Create a bit matrix from a Graph $g. The %opt, if present, can
29 have the following options:
30
31 • connect_edges
32
33 If true or if not present, set the bits in the bit matrix
34 that correspond to edges. If false, do not set any bits.
35 In either case the bit matrix of V x V bits is allocated.
36
37 • transpose
38
39 If true, set the bits in the bit matrix that correspond to
40 edges but in the reverse direction. This has the effect of
41 transposing the matrix. Obviously makes no difference to
42 the result for undirected graphs.
43
44 Object Methods
45 get($u, $v)
46 Return true if the bit matrix has a "one bit" between the vertices
47 $u and $v; in other words, if there is (at least one) a vertex
48 going from $u to $v. If there is no vertex and therefore a "zero
49 bit", return false.
50
51 set($u, $v)
52 Set the bit between the vertices $u and $v; in other words, connect
53 the vertices $u and $v by an edge. The change does not get
54 mirrored back to the original graph. Returns nothing.
55
56 unset($u, $v)
57 Unset the bit between the vertices $u and $v; in other words,
58 disconnect the vertices $u and $v by an edge. The change does not
59 get mirrored back to the original graph. Returns nothing.
60
61 get_row($u, $v1, $v2, ..., $vn)
62 Test the row at vertex "u" for the vertices "v1", "v2", ..., "vn"
63 Returns a list of n truth values.
64
65 set_row($u, $v1, $v2, ..., $vn)
66 Sets the row at vertex "u" for the vertices "v1", "v2", ..., "vn",
67 in other words, connects the vertex "u" to the vertices "vi". The
68 changes do not get mirrored back to the original graph. Returns
69 nothing.
70
71 unset_row($u, $v1, $v2, ..., $vn)
72 Unsets the row at vertex "u" for the vertices "v1", "v2", ...,
73 "vn", in other words, disconnects the vertex "u" from the vertices
74 "vi". The changes do not get mirrored back to the original graph.
75 Returns nothing.
76
77 vertices
78 Return the list of vertices in the bit matrix.
79
81 The algorithm used to create the matrix is two nested loops, which is
82 O(V**2) in time, and the returned matrices are O(V**2) in space.
83
85 Jarkko Hietaniemi jhi@iki.fi
86
88 This module is licensed under the same terms as Perl itself.
89
90
91
92perl v5.36.0 2022-07-22 Graph::BitMatrix(3)