File Coverage

blib/lib/Graph/MoreUtils.pm
Criterion Covered Total %
statement 24 25 96.0
branch n/a
condition n/a
subroutine 10 11 90.9
pod 4 4 100.0
total 38 40 95.0


line stmt bran cond sub pod time code
1             package Graph::MoreUtils;
2              
3             # ABSTRACT: Utilities for graphs
4             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     8   181209 use strict;
  8         18  
  8         301  
25 8     8   66 use warnings;
  8         52  
  8         529  
26              
27 8     8   3841 use parent Exporter::;
  8         3012  
  8         78  
28              
29 8     8   5286 use Graph::MoreUtils::Line;
  8         30  
  8         405  
30 8     8   4141 use Graph::MoreUtils::Replace;
  8         29  
  8         342  
31 8     8   5283 use Graph::MoreUtils::SSSR;
  8         28  
  8         365  
32 8     8   4087 use Graph::MoreUtils::Smooth;
  8         29  
  8         1130  
33              
34             our @EXPORT_OK = qw(
35             SSSR
36             graph_replace
37             line
38             smooth
39             );
40              
41             =head2 C
42              
43             Finds the Smallest Set of Smallest Rings (SSSR) in L objects.
44             Thus it should work with any L object.
45             The code is largely taken from the C package (L).
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, 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 stands for no limit.
51              
52             =cut
53              
54 2     2 1 307395 sub SSSR { &Graph::MoreUtils::SSSR::SSSR }
55              
56             =head2 C
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     0 1 0 sub graph_replace { &Graph::MoreUtils::Replace::replace }
64              
65             =head2 C
66              
67             Generates line graphs for L 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, 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.
75             This does not work with directed graphs yet.
76              
77             =cut
78              
79 10     10 1 1701713 sub line { &Graph::MoreUtils::Line::line }
80              
81             =head2 C
82              
83             Smooths the given graph by collating vertices of degree 2.
84              
85             =cut
86              
87 3     3 1 408203 sub smooth { &Graph::MoreUtils::Smooth::smooth }
88              
89             =head1 SEE ALSO
90              
91             perl(1)
92              
93             =head1 AUTHORS
94              
95             Andrius Merkys, Emerkys@cpan.orgE
96              
97             =cut
98              
99             1;