[Swift-commit] r6107 - SwiftApps/SciColSim
wilde at ci.uchicago.edu
wilde at ci.uchicago.edu
Mon Dec 17 18:15:14 CST 2012
Author: wilde
Date: 2012-12-17 18:15:14 -0600 (Mon, 17 Dec 2012)
New Revision: 6107
Added:
SwiftApps/SciColSim/samplegraph.sh
Log:
add script to downsample the graph
Added: SwiftApps/SciColSim/samplegraph.sh
===================================================================
--- SwiftApps/SciColSim/samplegraph.sh (rev 0)
+++ SwiftApps/SciColSim/samplegraph.sh 2012-12-18 00:15:14 UTC (rev 6107)
@@ -0,0 +1,52 @@
+#! /bin/sh
+
+fraction=${1:-1.0}
+
+tmp=$(mktemp -t samplegraph)
+
+awk '
+
+function crand()
+{
+ _cliff_seed = (100 * log(_cliff_seed)) % 1
+ if (_cliff_seed < 0)
+ _cliff_seed = - _cliff_seed
+ return _cliff_seed
+}
+
+BEGIN {
+ getmsec="perl -MTime::HiRes=gettimeofday -e \"print int(1000*gettimeofday()).qq(\\n);\""
+ getmsec | getline msec
+ close(getmsec)
+ _cliff_seed = (msec % 10000) / 10000
+ nv=0
+}
+
+NR == 1 { }
+
+(NR > 1) && (crand() < fraction) {
+ if ( $1 in vertices ) {
+ v1 = vertices[$1]
+ }
+ else {
+ vertices[$1] = v1 = nv++;
+ }
+ if ( $2 in vertices ) {
+ v2 = vertices[$2]
+ }
+ else {
+ vertices[$2] = v2 = nv++;
+ }
+ print v1, v2
+}
+
+END {print nv}
+
+' fraction=$fraction < big_graph.v01.txt >$tmp
+
+edges=$(wc -l <$tmp)
+vertices=$(tail -1 $tmp)
+
+echo $vertices $edges
+sed -e '$d' <$tmp
+rm $tmp
Property changes on: SwiftApps/SciColSim/samplegraph.sh
___________________________________________________________________
Added: svn:executable
+ *
More information about the Swift-commit
mailing list