Last change
on this file since 348 was 2, checked in by Rick van der Zwet, 15 years ago |
Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)
|
-
Property svn:executable
set to
*
|
File size:
852 bytes
|
Line | |
---|
1 | #!/usr/bin/env perl
|
---|
2 | # Generate random graph, for the sake of testing the genetic algoritms
|
---|
3 | # $Id: randgraph.pl 606 2008-05-12 15:37:58Z rick $
|
---|
4 | # Rick van der Zwet
|
---|
5 | # Licence: BSD
|
---|
6 |
|
---|
7 | $MAX_LENGTH=20;
|
---|
8 |
|
---|
9 | if ( not defined($ARGV[1]) ) {
|
---|
10 | print "Usage <program> <size_of_array> <CHANCE on arch>\n";
|
---|
11 | exit 1;
|
---|
12 | }
|
---|
13 |
|
---|
14 | $NODES = $ARGV[0];
|
---|
15 | $CHANCE = $ARGV[1];
|
---|
16 |
|
---|
17 | print "$NODES\n";
|
---|
18 | foreach $i (0 .. ($NODES-1)) {
|
---|
19 | foreach $j (0 .. ($NODES-1)) {
|
---|
20 | if ($i == $j) {
|
---|
21 | printf "%02i ", 0;
|
---|
22 | } elsif ($j < $i) {
|
---|
23 | printf "%02i ", $distance[$j][$i];
|
---|
24 | } else {
|
---|
25 | if (int(rand(100)) < $CHANCE) {
|
---|
26 | $length = int(rand($MAX_LENGTH)) + 1;
|
---|
27 | } else {
|
---|
28 | $length = 0;
|
---|
29 | }
|
---|
30 | $distance[$i][$j] = $length;
|
---|
31 | printf "%02i ", $length;
|
---|
32 | }
|
---|
33 | }
|
---|
34 | print "\n";
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.