bigworld

compute diameter of flights graph
git clone https://a3nm.net/git/bigworld/
Log | Files | Refs

commit ce7308f41d912747ce80fa24aa7fddf30810d97c
parent 12d9e95701e4483937ddd262cf0af32c6e25d06d
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Wed, 20 May 2015 23:50:25 +0200

retrieve data and save results

Diffstat:
smallworld.cpp | 4++--
smallworld.sh | 16+++++++++++++++-
2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/smallworld.cpp b/smallworld.cpp @@ -51,7 +51,7 @@ int main(int argc, char **argv) { // transitive closure within each company on non-MULTI segments for (unsigned int k = 0; k < n; k++) { if (!(k % STEP)) - printf ("closing: %d of %d\n", k, n); + fprintf(stderr, "closing: %d of %d\n", k, n); for (unsigned int i = 0; i < n; i++) for (unsigned int j = 0; j < n; j++) if (d[i][k] == 1 && d[k][j] == 1 && airline[i][k] == airline[k][j] @@ -64,7 +64,7 @@ int main(int argc, char **argv) { } for (unsigned int k = 0; k < n; k++) { if (!(k % STEP)) - printf ("computing: %d of %d\n", k, n); + fprintf(stderr, "computing: %d of %d\n", k, n); for (unsigned int i = 0; i < n; i++) for (unsigned int j = 0; j < n; j++) if (d[i][j] > d[i][k] + d[k][j]) { diff --git a/smallworld.sh b/smallworld.sh @@ -1,10 +1,22 @@ #!/bin/bash + +if [ ! -f airlines.dat ] + wget -O airlines.dat 'https://sourceforge.net/p/openflights/code/HEAD/tree/openflights/data/airlines.dat?format=raw' +fi + +if [ ! -f routes.dat ] + wget -O routes.dat + 'https://sourceforge.net/p/openflights/code/HEAD/tree/openflights/data/routes.dat?format=raw' +fi + cut -d ',' -f1,8 airlines.dat | tr -d '"' | tr ',' ' ' > active.dat echo "\\N Y" >> active.dat # sponge from moreutils sort -k1,1 active.dat | sponge active.dat + cut -d, -f2,3,5,7 routes.dat | grep -v 'Y$' | tr ',' ' ' | sort -k1,1 > routesb.dat + # all unregistered airlines get the same code # we rely on the fact that all \N come last join routesb.dat active.dat | @@ -16,6 +28,8 @@ join routesb.dat active.dat | print $0; n = n > $1?n:$1; } }' > routesc.dat + g++ -Wall -o smallworld -O3 smallworld.cpp -./smallworld close < routesc.dat +./smallworld close < routesc.dat > pairs.out +./smallworld < routesc.dat > pairs_close.out