import sys print('graph g {') with open(sys.argv[1]) as fh: for line in fh: line = line.rstrip() left, tail = line.split(': ', 1) for right in tail.split(): print(f' {left} -- {right};') print('}')