#Reverse of Romania
#Given info about travel time and cities visited
#determine the disatnce between cities

from render import *
from time import sleep

def readfile(a, file):
	s = open(file).read().split('\n')[:-1]
	for e in s:
		p,c = e.split(":")
		a.append((p.split(","),c))

def register(a, b, hash):
	if a in hash.keys():
		for k in hash[a]:
			if k[0] == b:
				return
		hash[a].append((b,0))

	else:
		hash[a] = [(b, 0)]

def build(p, hash):
	path,cost = p[0],p[1]
	last = path[0]
	for k in path[1:]:
		register(last, k, hash)
		register(k, last, hash)
		last = k

paths = []
readfile(paths, 'files/map.data')
d = {}
for k in paths:
	build(k, d)
render(d)
for k in d:
	print "%(key)s:%(val)s" % { 'key' : k, 'val' : d[k] }