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
|
#!/usr/bin/perl
die "Usage: plotorder.pl <graphfile> <orderfile> <sizesfile>\n" unless ($#ARGV == 2);
$graphfile = shift(@ARGV);
$orderfile = shift(@ARGV);
$sizesfile = shift(@ARGV);
#=========================================================================
# Read the graph file
#=========================================================================
open(FPIN, "<$graphfile");
$_ = <FPIN>;
chomp($_);
($nvtxs, $nedges, $flags) = split(' ', $_);
$readvw = $flags&2;
$readew = $flags&1;
$nnz = 0;
$xadj[0] = 0;
for ($i=0; $i<$nvtxs; $i++) {
$_ = <FPIN>;
chomp($_);
@fields = split(' ', $_);
$vwgt[$i] = shift(@fields) if ($readvw);
while (@fields) {
$adjncy[$nnz] = shift(@fields)-1;
$adjwgt[$nnz] = shift(@fields) if ($readew);
$nnz++;
}
$xadj[$i+1] = $nnz;
}
close(FPIN);
|