def perfect_weighted_distance(reference: dict) -> int:
    """
    The nature of the algorithm causes some double counting to occur when we are
    recording contig lengths. Here we find out what the "length" of a completely
    correct assembly would be, and use that as the max length. 

    Args:
        reference: The reference AGP dictionary. 

    Returns:
        The maximum possible length from a completely correct assembly. 
    """

    contigs, positions = reference
    length = 0

    for index in positions:

        # Get the total length for each edge.
        for contig_name, orientation in positions[index]:
            length += contigs[contig_name]["length"]

    return length