#!/bin/sh

#
# Graham Phillips <graham@isi.edu>
# Los Angeles,  February 2000.
#
# This program converts a topology represented as a file with two 
# columns into and adjacency list format.  Any duplicated edges are
# suppressed. 
# See http://www.isi.edu/~graham/contrib/index.html for more
# information.
 
if [ "$1" = "" ] ; then 
	echo "Usage: edges2adj <edges-file>"
	echo "   This program converts a file containing edges represented as two columns"
	echo "   to an adjacency list format.  The output adjacency file is written to stdout."
	echo "   See http://www.isi.edu/~graham/contrib/index.html for more"
	echo "   information." 
	exit
fi
# number of vertices
cat $1 | tr ' ' '\012' | sort | uniq | wc | awk '{printf "%d ", $1}'

# number of edges
cat $1 | awk '{if (NR > 1) print}' | sort | uniq | wc | awk '{print $1}'

# list non-duplicate edges
cat $1 | awk '{if (NR > 1) print}' | sort | uniq
