| 1 | package Graph::MoreUtils; | ||
| 2 | |||
| 3 | # ABSTRACT: Utilities for graphs | ||
| 4 | 8 | our $VERSION = '0.3.0'; # VERSION | |
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | Graph::MoreUtils - utilities for graphs | ||
| 9 | |||
| 10 | =head1 SYNOPSIS | ||
| 11 | |||
| 12 | use Graph::MoreUtils qw( line ); | ||
| 13 | use Graph::Undirected; | ||
| 14 | |||
| 15 | my $G = Graph::Undirected->new; | ||
| 16 | |||
| 17 | # Greate graph here | ||
| 18 | |||
| 19 | # Get line graph for $G: | ||
| 20 | my $L = line( $G ); | ||
| 21 | |||
| 22 | =cut | ||
| 23 | |||
| 24 | 8 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 25 | 8 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 26 | |||
| 27 | 8 | ▶ | use parent Exporter::; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 28 | |||
| 29 | 8 | ▶ | use Graph::MoreUtils::Line; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 30 | 8 | ▶ | use Graph::MoreUtils::Replace; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 31 | 8 | ▶ | use Graph::MoreUtils::SSSR; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 32 | 8 | ▶ | use Graph::MoreUtils::Smooth; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 33 | |||
| 34 | 8 | our @EXPORT_OK = qw( | |
| 35 | SSSR | ||
| 36 | graph_replace | ||
| 37 | line | ||
| 38 | smooth | ||
| 39 | ); | ||
| 40 | |||
| 41 | =head2 C<SSSR( $graph, $max_depth )> | ||
| 42 | |||
| 43 | Finds the Smallest Set of Smallest Rings (SSSR) in L<Graph> objects. | ||
| 44 | Thus it should work with any L<Graph::Undirected> object. | ||
| 45 | The code is largely taken from the C<cod-tools> package (L<https://wiki.crystallography.net/cod-tools/>). | ||
| 46 | |||
| 47 | The algorithm returns a superset of minimum cycle basis of a graph in order to produce deterministic results. | ||
| 48 | As a result it does not succumb to the counterexample of oxabicyclo[2.2.2]octane (L<https://depth-first.com/articles/2020/08/31/a-smallest-set-of-smallest-rings/>, section "SSSR and Uniqueness"). | ||
| 49 | The algorithm has means to control the maximum size of rings included in the SSSR to reduce its complexity. | ||
| 50 | The default value of C<undef> stands for no limit. | ||
| 51 | |||
| 52 | =cut | ||
| 53 | |||
| 54 | 2 | ▶ | sub SSSR { &Graph::MoreUtils::SSSR::SSSR } |
|
Subroutine
SSSR: called CC=1 SCAR=0.0
Pod
documented
| |||
| 55 | |||
| 56 | =head2 C<graph_replace( $graph, $new, @old )> | ||
| 57 | |||
| 58 | Replaces one or more vertices (C<@old>) in the graph with a given one (C<$new>). | ||
| 59 | All edges between the replaced vertices are removed and all edges with other vertices become a reconnected to the new one. | ||
| 60 | |||
| 61 | =cut | ||
| 62 | |||
| 63 | 0 | ▶ | sub graph_replace { &Graph::MoreUtils::Replace::replace } |
|
Subroutine
graph_replace: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 64 | |||
| 65 | =head2 C<line( $graph )> | ||
| 66 | |||
| 67 | Generates line graphs for L<Graph> objects. | ||
| 68 | Line graph is constructed nondestructively and returned from the call. | ||
| 69 | Both simple and multiedged, undirected and directed graphs are supported. | ||
| 70 | |||
| 71 | Call accepts additional options hash. | ||
| 72 | Currently only one option is supported, C<loop_end_vertices>, which treats the input graph as having self-loops on pendant vertices, that is, increasing the degrees of vertices having degrees of 1. | ||
| 73 | Thus they are not "lost" during line graph construction. | ||
| 74 | In the resulting line graph these self-loops are represented as instances of L<Graph::MoreUtils::Line::SelfLoopVertex>. | ||
| 75 | This does not work with directed graphs yet. | ||
| 76 | |||
| 77 | =cut | ||
| 78 | |||
| 79 | 10 | ▶ | sub line { &Graph::MoreUtils::Line::line } |
|
Subroutine
line: called CC=1 SCAR=0.0
Pod
documented
| |||
| 80 | |||
| 81 | =head2 C<smooth( $graph )> | ||
| 82 | |||
| 83 | Smooths the given graph by collating vertices of degree 2. | ||
| 84 | |||
| 85 | =cut | ||
| 86 | |||
| 87 | 3 | ▶ | sub smooth { &Graph::MoreUtils::Smooth::smooth } |
|
Subroutine
smooth: called CC=1 SCAR=0.0
Pod
documented
| |||
| 88 | |||
| 89 | =head1 SEE ALSO | ||
| 90 | |||
| 91 | perl(1) | ||
| 92 | |||
| 93 | =head1 AUTHORS | ||
| 94 | |||
| 95 | Andrius Merkys, E<lt>merkys@cpan.orgE<gt> | ||
| 96 | |||
| 97 | =cut | ||
| 98 | |||
| 99 | 8 | 1; | |