]> granicus.if.org Git - graphviz/commitdiff
Replace maxdeg.g with richer script
authorerg <devnull@localhost>
Fri, 8 Apr 2011 20:03:19 +0000 (20:03 +0000)
committererg <devnull@localhost>
Fri, 8 Apr 2011 20:03:19 +0000 (20:03 +0000)
cmd/gvpr/lib/maxdeg.g

index c63535bc9faaf4808cd877bab682eeef01a09528..c61f2313cbb72b71de0bb65411a11bd21d42422d 100644 (file)
@@ -1,4 +1,10 @@
-/* find node of max degree */
-BEGIN {node_t n; int maxd = -1; }
-N { if (degree > maxd) {maxd = degree; n = $;} }
-END {printf ("max degree = %d, node %s\n", maxd, n.name)}
+/* find nodes of max and min degree */
+BEG_G {node_t mxn, mnn; int maxd = -1; int mind = 1000000;}
+N { 
+if (degree > maxd) 
+{maxd = degree; mxn = $;} 
+if (degree < mind) 
+{mind = degree; mnn = $;} 
+}
+END_G {printf ("max degree = %d, node %s, min degree = %d, node %s\n", 
+  maxd, mxn.name, mind, mnn.name)}