Ejemplo n.º 1
0
bool TestGraphModify::check_adjacency()
{
    assert(SC_ADDR_IS_NOT_EMPTY(mGraphAddr));

    sc_addr v1, v2, v3, arc;

    if (sc_graph_create_vertex(mGraphAddr, &v1) != SC_RESULT_OK)
        return false;
    if (sc_graph_create_vertex(mGraphAddr, &v2) != SC_RESULT_OK)
        return false;
    if (sc_graph_create_vertex(mGraphAddr, &v3) != SC_RESULT_OK)
        return false;
    if (sc_graph_create_arc(mGraphAddr, v1, v2, &arc) != SC_RESULT_OK)
        return false;

    if (sc_graph_check_elements_adjacency(mGraphAddr, v1, v2) != SC_RESULT_OK)
        return false;

    if (sc_graph_check_elements_adjacency(mGraphAddr, v1, v3) == SC_RESULT_OK)
        return false;

    if (sc_graph_check_elements_adjacency(mGraphAddr, v2, v3) == SC_RESULT_OK)
        return false;

    return true;
}
Ejemplo n.º 2
0
sc_addr find_adjacent_from_wave(sc_addr graph, sc_addr wave, sc_addr curr_vertex)
{
    sc_iterator3 *it3;

    it3 = sc_iterator3_f_a_a_new(wave,
                                 sc_type_arc_pos_const_perm,
                                 sc_type_node | sc_type_const);

    while (sc_iterator3_next(it3) == SC_TRUE)
        if (sc_graph_check_elements_adjacency(graph, curr_vertex, it3->results[2]) == SC_RESULT_OK)
            return it3->results[2];
}