def printFlows(options, edgeFlow, detReader): edgeIDCol = "edge " if options.edgenames else "" print('# detNames %sRouteFlow DetFlow ratio' % edgeIDCol, file=options.outfile) output = [] for edge, detData in detReader._edge2DetData.items(): detString = [] dFlow = [] for group in detData: if group.isValid: groupName = os.path.commonprefix(group.ids) if groupName == "" or options.longnames: groupName = ';'.join(sorted(group.ids)) detString.append(groupName) dFlow.append(group.totalFlow) rFlow = len(detString) * [edgeFlow.get(edge, 0)] edges = len(detString) * [edge] output.extend(zip(detString, edges, rFlow, dFlow)) for group, edge, rflow, dflow in sorted(output): if dflow > 0 or options.respectzero: if options.edgenames: print(group, edge, repr(rflow), repr(dflow), repr(relError(rflow, dflow)), file=options.outfile) else: print(group, repr(rflow), repr(dflow), repr(relError(rflow, dflow)), file=options.outfile)
def printFlows(options, edgeFlow, detReader): edgeIDCol = "edge " if options.edgenames else "" print('# detNames %sRouteFlow DetFlow ratio' % edgeIDCol, file=options.outfile) output = [] for edge, detData in detReader._edge2DetData.items(): detString = [] dFlow = [] for group in detData: if group.isValid: groupName = os.path.commonprefix(group.ids) if groupName == "" or options.longnames: groupName = ';'.join(sorted(group.ids)) detString.append(groupName) dFlow.append(group.totalFlow) rFlow = len(detString) * [edgeFlow.get(edge, 0)] edges = len(detString) * [edge] output.extend(zip(detString, edges, rFlow, dFlow)) for group, edge, rflow, dflow in sorted(output): if dflow > 0 or options.respectzero: if options.edgenames: print(group, edge, repr(rflow), repr(dflow), repr(relError(rflow, dflow)), file=options.outfile) else: print(group, repr(rflow), repr(dflow), repr(relError(rflow, dflow)), file=options.outfile)