if printOutput: print("Graph Edges (total {m})".format(m=self._graph.numEdges())) for (edgeID, edgeObj) in self._graph._edges.items(): if printOutput: print("\t({ID}) {src!s} -- {dest!s} [{weight:.2f}]".format( ID=edgeID, src=self._graph._verts[edgeObj.fromVert], dest=self._graph._verts[edgeObj.toVert], weight=edgeObj.weight)) totalWeight += edgeObj.weight if printOutput: print("Total weight: {weight:.2f}".format(weight=totalWeight)) return totalWeight if __name__ == "__main__": a = Vertex(0, 15, "A") b = Vertex(5, 20, "B") c = Vertex(16, 24, "C") d = Vertex(20, 20, "D") e = Vertex(33, 25, "E") f = Vertex(23, 11, "F") g = Vertex(35, 7, "G") h = Vertex(25, 0, "H") i = Vertex(10, 3, "I") grid = NaiveHananSolver([a,b,c,d,e,f,g,h,i]) grid.addStationWeightFunc(lambda g,v: 1.2 * pow(g.getDegreeOfVertex(v), 1.5)) grid.solve() grid.graphStats(printOutput=True) grid.plotGraph()