Example #1
0
def check_triangulation(embedding, expected_embedding):
    res_embedding, _ = triangulate_embedding(embedding, True)
    assert_equals(res_embedding.get_data(), expected_embedding,
                  "Expected embedding incorrect")
    res_embedding, _ = triangulate_embedding(embedding, False)
    assert_equals(res_embedding.get_data(), expected_embedding,
                  "Expected embedding incorrect")
Example #2
0
def check_triangulation(embedding, expected_embedding):
    res_embedding, _ = triangulate_embedding(embedding, True)
    assert_equals(res_embedding.get_data(), expected_embedding,
                  "Expected embedding incorrect")
    res_embedding, _ = triangulate_embedding(embedding, False)
    assert_equals(res_embedding.get_data(), expected_embedding,
                  "Expected embedding incorrect")
Example #3
0
def compute_pos(embedding: nx.PlanarEmbedding,
                external_face: tuple = None) -> Tuple[List[int], List[int]]:
    """Triangulates the graph, computes a canonical ordering and use it to compute a planar drawing on a grid.

    :param embedding: The planar embedding of the graph.
    :param external_face: If this parameter is specified, the graph is considered as already triangulated.
    :return:
        A tuple (x_pos, y_pos) where x_pos is a list that maps vertices to their x-positions and y_pos a list that maps
        vertices to their y-positions.
    """
    if external_face is None:
        embedding_t, external_face = triangulate_embedding(embedding)
    else:
        embedding_t = embedding
    ordering, wpq_list = get_canonical_ordering(embedding_t, external_face)
    x, y = shift_algorithm(ordering, wpq_list)
    return x, y