#!/usr/bin/env python# encoding: utf-8"""undirect.pyCreated by Michele Catasta on 2007-06-23.Checks if a graph contained in a DIMACS .gr file is undirect.Silent output if positive.Usage: python undirect.py FILE_NAME.gr"""import sysimport osdef main():		f = open(sys.argv[1],"r")		# skips comments and additional infos	while 1:		start = f.tell()		header = f.readline()[0:1]				if header != 'a':			pass		else:			f.seek(start)			break		i = iter(f)		# undirectness check	try:		while True:			oddline = i.next()			evenline = i.next()						a1, b1, w1 = oddline.split(" ")[1:4]			b2, a2, w2 = evenline.split(" ")[1:4]						if(a1 != a2 or b1 != b2 or w1 != w2):				print "Given graph IS direct."				break	except StopIteration:		passif __name__ == '__main__':    main()