line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## |
2
|
|
|
|
|
|
|
# NAME |
3
|
|
|
|
|
|
|
# Pixie::ObjectGraph - graph of associated object id's in a Pixie store |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# SYNOPSIS |
6
|
|
|
|
|
|
|
# use Pixie::ObjectGraph; |
7
|
|
|
|
|
|
|
# my $graph = Pixie::ObjectGraph->new; |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# $graph->add_edge( $oid_source => $oid_dest1 ) |
10
|
|
|
|
|
|
|
# ->add_edge( $oid_source => $oid_dest2 ); |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# @oids = $graph->neighbours( $oid_source ); # dest1-2 |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# DESCRIPTION |
15
|
|
|
|
|
|
|
# ObjectGraphs look like this internally: |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
# $graph = { |
18
|
|
|
|
|
|
|
# source_oid1 => [qw( dest_oid1, dest_oid2, dest_oid3 )], |
19
|
|
|
|
|
|
|
# source_oid2 => [qw( dest_oid1, dest_oid4, dest_oid5 )], |
20
|
|
|
|
|
|
|
# ... |
21
|
|
|
|
|
|
|
# }; |
22
|
|
|
|
|
|
|
## |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package Pixie::ObjectGraph; |
25
|
|
|
|
|
|
|
|
26
|
25
|
|
|
25
|
|
29331
|
use strict; |
|
25
|
|
|
|
|
53
|
|
|
25
|
|
|
|
|
883
|
|
27
|
25
|
|
|
25
|
|
132
|
use warnings; |
|
25
|
|
|
|
|
46
|
|
|
25
|
|
|
|
|
5863
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our $VERSION = '2.08_02'; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# TODO: Pixie::Object has a constructor - use it? |
32
|
|
|
|
|
|
|
sub new { |
33
|
25
|
|
|
25
|
0
|
2106
|
my $proto = shift; |
34
|
25
|
|
|
|
|
105
|
return bless {}, $proto; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
## TODO: rename 'associate_oids' ? |
38
|
|
|
|
|
|
|
sub add_edge { |
39
|
3
|
|
|
3
|
0
|
8
|
my $self = shift; |
40
|
3
|
|
|
|
|
6
|
my($source => $dest) = @_; |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
5
|
push @{$self->{$source}}, $dest; |
|
3
|
|
|
|
|
14
|
|
43
|
3
|
|
|
|
|
13
|
return $self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
## TODO: rename 'edges'? 'associated_oids'? |
47
|
|
|
|
|
|
|
sub neighbours { |
48
|
5
|
|
|
5
|
0
|
13
|
my $self = shift; |
49
|
5
|
|
|
|
|
10
|
my $source = shift; |
50
|
5
|
100
|
|
|
|
26
|
my @retary = exists($self->{$source}) ? @{$self->{$source}} : (); |
|
4
|
|
|
|
|
9
|
|
51
|
5
|
100
|
|
|
|
26
|
wantarray ? @retary : [@retary]; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub add_graph { |
55
|
1
|
|
|
1
|
0
|
16
|
my $self = shift; |
56
|
1
|
|
|
|
|
3
|
my $other_graph = shift; |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
4
|
@{$self}{keys %$other_graph} = values %$other_graph; |
|
1
|
|
|
|
|
2
|
|
59
|
1
|
|
|
|
|
5
|
return $self; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |