def get_node_set_map(tuple_list):
    """
    Function to get a mapping of random node names to values between 0
    and number of nodes - 1, with a modified adjacency list.

    Args:
        tuple_list : adjacency list with weights and arbitrary node names

    Returns:
        tuples : canonicalized adjacency list
        node_map : mapping from node name to index
    """
    node_set = set()
    for tpl in tuple_list:
        node_set.update(tpl[:2])
    node_map = {node_name: idx for idx, node_name in enumerate(node_set)}
    tuples = [(node_map[src], node_map[dst], wgt) for src, dst, wgt in tuple_list]
    return tuples, node_map