This file is indexed.

/usr/share/perl5/GIFT/CGraphCollection.pm is in gnuift-perl 0.1.14-12.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#!/usr/bin/perl -w # -*- mode: perl -*-

#     GIFT, a flexible content based image retrieval system.
#     Copyright (C) 1998, 1999, 2000, 2001, 2002, CUI University of Geneva

#     This program is free software; you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation; either version 2 of the License, or
#     (at your option) any later version.

#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.

#     You should have received a copy of the GNU General Public License
#     along with this program; if not, write to the Free Software
#     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#!/usr/bin/perl -w

use POSIX ;#(floor ceil)

=pod

This class addresses the problem of constructing a graph from
many graphs. In general this will be something like constucting an 
average graph from a graph. 

To a graph collection, you can add point lists, which will be treated like
a non-closed polygon drawing 

You can unite two collections,
and you can turn the collection into a string.

=cut



package CGraphCollection;
require Exporter;
@ISA    = qw(Exporter);
@EXPORT = qw(new
	     init
	     addPointList
	     unite
	     toString
	     transform
	     output);


###############################
#
# constructs a new graph collection
# Parameters
# from, to, stepwidth
sub new( $;){
  my $class=shift;
  my $self={};
  
  bless $self,$class;
  
  $self->init(@_);
  return $self;
}

sub init{
  my$self=shift;
  my $inFrom=shift;
  my $inTo=shift;
  my $inStepWidth=shift;
  
  my @lPlot;
  my $i;
  for($i=$inFrom;
      $i<=$inTo;
      $i+=$inStepWidth){
    push @lPlot,[$i,[]];	# an X and a List of Ys
  }
  $self->{from}=$inFrom;
  $self->{to}=$inFrom;
  $self->{stepWidth}=$inStepWidth;
  $self->{points}=\@lPlot;
}


###############################
#
# transform a value into an array index
#
#
sub xToIndex( $ ){
  my$self=shift;
  my $inX=shift;
  
  return POSIX::floor(
		      ($inX-$self->{from})/$self->{stepWidth}
		     );
}

###############################
#
# Add a  list of points to the graph.
# the points are given as a flat list
# of values in the sequence x,y,x,y...
#
sub addPointList( @ ){
  my$self=shift;
  my($oldX,$oldY);
  my($x,$y);
  
  while(defined($x=shift) && defined($y=shift)){
    
    if(defined($oldX) && defined($oldY)){
      my $lFrom=$self->xToIndex($oldX);
      my $lTo=$self->xToIndex($x);
      my $lSteps=$lTo-$lFrom;


      my $lDifference=0;
      my @lIteratorList;
      if($lSteps>=1){
	@lIteratorList=($lFrom..($lTo-1));
	$lDifference=($y-$oldY)/$lSteps;
      }else{
	$lDifference=0;
	@lIteratorList=($lFrom);
      }
      
      print "($x;$y) $lFrom $lTo STEPS: $lSteps, $lDifference\n" if($self->{DEBUG}->{addPointList});

      my $i;
      
      for $i (@lIteratorList){
	my $lPushValue=$oldY+(($i-$lFrom)
			      *$lDifference);
	if($self->{DEBUG}->{addPointList}){
	  print "pushing into $i the value ",$lPushValue,"\n";
	}
	push (@{$self->{points}->[$i]->[1]},
	      $lPushValue);
      }
#      print "ENDFOR\n";
    }
    $oldX=$x;
    $oldY=$y;
  }
  if(defined($oldX) && defined($oldY)){
    push (@{$self->{points}->[$self->xToIndex($oldX)]->[1]},
	  $oldY+($lSteps*$lDifference));
  }
}

###############################
#
# unite the data in two graphcollections
# in a way that they can be used for the calculation
# of averages etc.
sub unite{
  my$self=shift;
  my $inGraph=shift;
  
  print "uniting $self with $inGraph\n";

  if($self->{from}==
     $inGraph->{from}
     and
     $self->{to}==
     $inGraph->{to}
     and
     $self->{stepWidth}==
     $inGraph->{stepWidth}
    ){
    #simply splice the lists
    my $i;
    
    my $endfor=scalar(@{$self->{points}});
    for($i=0;
	$i<$endfor;
	$i++){
      @{$self->{points}->[$i]->[1]}=
	(@{$self   ->{points}->[$i]->[1]},
	 @{$inGraph->{points}->[$i]->[1]});
    }
  }else{
    die "Graph parameters are not the same!\n";
  }
}

###############################
#
# turn this list of point lists into a string
# using a string to evaluate
# this string assumes to be fed its data in $lPoint 
# (one list of x value and y values
sub toString( ;$ ){
  my$self=shift;
  my $lResult;
  my $printer=shift || 
    '
  my($lSum,$i);

  foreach $i (@{$lPoint->[1]}){
   $lSum+=$i;
   $lSquareSum+=$i*$i;
  }

  if(defined($lSum)){
    my $lAverage=$lSum/scalar(@{$lPoint->[1]});

    $lResult.= "$lPoint->[0], Average: $lAverage, Points: ";
    foreach $i (@{$lPoint->[1]}){
      $lResult.="$i ";
    }
    $lResult.="\n";
  }
';
  my $lPoint;
  foreach $lPoint (@ {$self->{points}}){
    eval($printer);
    if($@){
      print "an eval error occurred $@\n";
    }
  }
  return $lResult;
}
###############################
#
# like toString it allows looking
# at each element of the list,
# however, it does not print
sub transform( ;$ ){
  my$self=shift;
  my $lResult;
  my $printer=shift || 
    '
  my($lSum,$i);

  foreach $i (@{$lPoint->[1]}){
   $lSum+=$i;
   $lSquareSum+=$i*$i;
  }

  if(defined($lSum)){
    my $lAverage=$lSum/scalar(@{$lPoint->[1]});

    $lResult.= "$lPoint->[0], Average: $lAverage, Points: ";
    foreach $i (@{$lPoint->[1]}){
      $lResult.="$i ";
    }
    $lResult.="\n";
  }
';
  my $lPoint;
  foreach $lPoint (@ {$self->{points}}){
    eval($printer);
  }
  return $lResult;
}