perlrdf/Command/Isomorphic.pm

filter: Statementstmt 66.0% 35 / 53 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 100% 1 / 1 totaltotal 59.2% 48 / 81 CC 8 SCAR 31.5
CC
8
Cov
52%
execute
56.9
BEGIN
1.0
BEGIN
1.0
CRAP 23.4
« perlrdf/FileSpec/OutputRDF.pm ↑ Summary perlrdf/Command/StoreDump.pm »
1 package App::perlrdf::Command::Isomorphic;
2  
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 $App::perlrdf::Command::Isomorphic::AUTHORITY = 'cpan:TOBYINK';
10 1 $App::perlrdf::Command::Isomorphic::VERSION = '0.006';
11 }
12  
13 1 ▶use App::perlrdf -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 sub graph (_) { RDF::Trine::Graph->new(shift) };
15 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 ▶use constant abstract => q (Determine if two graphs are isomorphic.);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use constant command_names => qw( isomorphic );
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use constant opt_spec => (
Subroutine BEGIN: called CC=1 SCAR=0.0
21 [ 'input|i=s@', 'Input filename or URL' ],
22 [ 'input-spec|I=s@', 'Input file specification' ],
23 [ 'input-format|p=s', 'Input format (mnemonic: parse)' ],
24 [ 'input-base|b=s', 'Input base URI' ],
25 1 );
26 1 ▶use constant usage_desc => '%c isomorphic %o INPUT1 INPUT2';
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 sub execute
29 0 ▶{
Subroutine execute: not called CC=8 SCAR=40.4
Pod documented
30 0 require App::perlrdf::FileSpec::InputRDF;
31 0 require RDF::Trine::Graph;
32
33 0 my ($self, $opt, $arg) = @_;
34
35 0 my @inputs = $self->get_filespecs(
36 'App::perlrdf::FileSpec::InputRDF',
37 input => $opt,
38 );
39
40 push @inputs, map {
41 0 App::perlrdf::FileSpec::InputRDF->new_from_filespec(
42 $_,
43 $opt->{input_format},
44 $opt->{input_base},
45 )
46 0 } @$arg;
47  
48 push @inputs,
49 App::perlrdf::FileSpec::InputRDF->new_from_filespec(
50 '-',
51 $opt->{input_format},
52 $opt->{input_base},
53 )
54 0 ▶ unless @inputs >= 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @inputs >= 2 0 0 0
55  
56 0 ▶ $self->usage_error("Must provide exactly two inputs!")
Branch: 1 branch
BranchTrueFalseTotal
unless @inputs == 2 0 0 0
57 unless @inputs == 2;
58
59 0 my ($i1, $i2) = @inputs;
60 my ($m1, $m2) = map {
61 0 my $m = RDF::Trine::Model->new;
62 0 $_->parse_into_model($m);
63 0 $m;
64 } $i1, $i2;
65 0 my ($g1, $g2) = map graph, $m1, $m2;
66
67 1 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
68 0 ▶ if ($m1->size == $m2->size)
Branch: 2 branches
BranchTrueFalseTotal
if ($m1->size == $m2->size) { } 0 0 0
elsif ($m1->size < $m2->size) { } 0 0 0
69 {
70 0 ▶ say $g1->equals($g2)
Branch: 1 branch
BranchTrueFalseTotal
$g1->equals($g2) ? : 0 0 0
71 ? "graphs are isomorphic"
72 : sprintf("graphs differ: %s", $g1->error);
73 }
74 elsif ($m1->size < $m2->size)
75 {
76 0 ▶ say $g1->is_subgraph_of($g2)
Branch: 1 branch
BranchTrueFalseTotal
$g1->is_subgraph_of($g2) ? : 0 0 0
77 ? sprintf("%s is a subgraph of %s", $i1->uri, $i2->uri)
78 : sprintf("graphs differ: %s", $g1->error);
79 }
80 else
81 {
82 0 ▶ say $g2->is_subgraph_of($g1)
Branch: 1 branch
BranchTrueFalseTotal
$g2->is_subgraph_of($g1) ? : 0 0 0
83 ? sprintf("%s is a supergraph of %s", $i1->uri, $i2->uri)
84 : sprintf("graphs differ: %s", $g2->error);
85 }
86 }
87  
88 1 1;
89  
« perlrdf/FileSpec/OutputRDF.pm ↑ Summary perlrdf/Command/StoreDump.pm »