used python networkx to solve problem 82
output formatting