Exemple #1
0
def prepare_routes(node_dictionary):
    """Creates a map of nodes using the processed raw graph data.

    Args:
        node_dictionary (dict): mapping of a node to its output nodes
                                and respective distance.
    Returns:
        Route: a Route object containing all the Node objects.
    """
    route = Route()
    for item in node_dictionary:
        node = Node(item)
        for tup in node_dictionary[item]:
            output_node = tup[0]
            distance = tup[1]
            node.add_output_node(output_node, distance)
        route.add_node(node)
        route.name_node_dictionary[node.code] = node
    return route