.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Graph::AdjacencyMatrix 3pm" .TH Graph::AdjacencyMatrix 3pm "2018-07-31" "perl v5.26.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Graph::AdjacencyMatrix \- create and query the adjacency matrix of graph G .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Graph::AdjacencyMatrix; \& use Graph::Directed; # or Undirected \& \& my $g = Graph::Directed\->new; \& $g\->add_...(); # build $g \& \& my $am = Graph::AdjacencyMatrix\->new($g); \& $am\->is_adjacent($u, $v) \& \& my $am = Graph::AdjacencyMatrix\->new($g, distance_matrix => 1); \& $am\->distance($u, $v) \& \& my $am = Graph::AdjacencyMatrix\->new($g, attribute_name => \*(Aqlength\*(Aq); \& $am\->distance($u, $v) \& \& my $am = Graph::AdjacencyMatrix\->new($g, ...); \& my @V = $am\->vertices(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" You can use \f(CW\*(C`Graph::AdjacencyMatrix\*(C'\fR to compute the adjacency matrix and optionally also the distance matrix of a graph, and after that query the adjacencyness between vertices by using the \f(CW\*(C`is_adjacent()\*(C'\fR method, or query the distance between vertices by using the \&\f(CW\*(C`distance()\*(C'\fR method. .PP By default the edge attribute used for distance is \f(CW\*(C`w\*(C'\fR, but you can change that in \fInew()\fR, see below. .PP If you modify the graph after creating the adjacency matrix of it, the adjacency matrix and the distance matrix may become invalid. .SH "Methods" .IX Header "Methods" .SS "Class Methods" .IX Subsection "Class Methods" .IP "new($g)" 4 .IX Item "new($g)" Construct the adjacency matrix of the graph \f(CW$g\fR. .IP "new($g, options)" 4 .IX Item "new($g, options)" Construct the adjacency matrix of the graph \f(CW$g\fR with options as a hash. The known options are .RS 4 .IP "distance_matrix => boolean" 8 .IX Item "distance_matrix => boolean" By default only the adjacency matrix is computed. To compute also the distance matrix, use the attribute \f(CW\*(C`distance_matrix\*(C'\fR with a true value to the \fInew()\fR constructor. .IP "attribute_name => attribute_name" 8 .IX Item "attribute_name => attribute_name" By default the edge attribute used for distance is \f(CW\*(C`w\*(C'\fR. You can change that by giving another attribute name with the \f(CW\*(C`attribute_name\*(C'\fR attribute to \fInew()\fR constructor. Using this attribute also implicitly causes the distance matrix to be computed. .RE .RS 4 .RE .SS "Object Methods" .IX Subsection "Object Methods" .ie n .IP "is_adjacent($u, $v)" 4 .el .IP "is_adjacent($u, \f(CW$v\fR)" 4 .IX Item "is_adjacent($u, $v)" Return true if the vertex \f(CW$v\fR is adjacent to vertex \f(CW$u\fR, or false if not. .ie n .IP "distance($u, $v)" 4 .el .IP "distance($u, \f(CW$v\fR)" 4 .IX Item "distance($u, $v)" Return the distance between the vertices \f(CW$u\fR and \f(CW$v\fR, or \f(CW\*(C`undef\*(C'\fR if the vertices are not adjacent. .IP "adjacency_matrix" 4 .IX Item "adjacency_matrix" Return the adjacency matrix itself (a list of bitvector scalars). .IP "vertices" 4 .IX Item "vertices" Return the list of vertices (useful for indexing the adjacency matrix). .SH "ALGORITHM" .IX Header "ALGORITHM" The algorithm used to create the matrix is two nested loops, which is O(V**2) in time, and the returned matrices are O(V**2) in space. .SH "SEE ALSO" .IX Header "SEE ALSO" Graph::TransitiveClosure, Graph::BitMatrix .SH "AUTHOR AND COPYRIGHT" .IX Header "AUTHOR AND COPYRIGHT" Jarkko Hietaniemi \fIjhi@iki.fi\fR .SH "LICENSE" .IX Header "LICENSE" This module is licensed under the same terms as Perl itself.