diff --git a/deps/igraph-0.10.x/CMakeLists.txt b/deps/igraph-0.10.x/CMakeLists.txt index 67d4b88ce70..07d2d1b3dec 100644 --- a/deps/igraph-0.10.x/CMakeLists.txt +++ b/deps/igraph-0.10.x/CMakeLists.txt @@ -10,13 +10,18 @@ set (HAVE_IGRAPH TRUE) message("-- IGRAPH version 0.10.11 : download and build libigraph${CMAKE_SHARED_LIBRARY_SUFFIX} in ${IGRAPH_BASE}") +#Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24 +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") + cmake_policy(SET CMP0135 NEW) +endif() + ExternalProject_Add(igraph_0_10 PREFIX "${IGRAPH_INSTALL}" URL "https://github.com/igraph/igraph/releases/download/0.10.11/igraph-0.10.11.tar.gz" SOURCE_DIR "${IGRAPH_DOWNLOAD}" CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${IGRAPH_INSTALL}" "-DBUILD_SHARED_LIBS=ON" "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" "-Wno-deprecated" "-DIGRAPH_VERSION=0.9.10" BINARY_DIR "${IGRAPH_BUILD}" - PATCH_COMMAND echo PATCH + PATCH_COMMAND echo "No patch for igraph-0.10.x required" INSTALL_DIR "${IGRAPH_INSTALL}" BUILD_BYPRODUCTS "${IGRAPH_LIB}" ) diff --git a/deps/igraph-0.10.x/patch.txt b/deps/igraph-0.10.x/patch.txt deleted file mode 100644 index 6a17e51e595..00000000000 --- a/deps/igraph-0.10.x/patch.txt +++ /dev/null @@ -1,26 +0,0 @@ ---- igraph/download/src/CMakeLists.txt 2023-01-18 22:39:25.961620904 +0100 -+++ igraph/download/src/CMakeLists.txt 2023-01-18 22:39:48.945900413 +0100 -@@ -295,8 +295,8 @@ - ) - - # Set soname for the library --set_target_properties(igraph PROPERTIES VERSION "0.0.0") --set_target_properties(igraph PROPERTIES SOVERSION 0) -+set_target_properties(igraph PROPERTIES VERSION "2.0.0") -+set_target_properties(igraph PROPERTIES SOVERSION 2) - - # Add extra compiler definitions if needed - target_compile_definitions( ---- igraph/download/etc/cmake/compilers.cmake 2023-02-02 21:15:06.216428366 +0100 -+++ igraph/download/etc/cmake/compilers.cmake 2023-02-02 21:16:02.696814096 +0100 -@@ -32,8 +32,8 @@ - # GCC-style compilers: - $<$: - $<$:-Werror> -- -Wall -Wextra -pedantic -- -Wno-unused-function -Wno-unused-parameter -Wno-sign-compare -+ -Wall -Wextra -Wno-unused-but-set-variable -Wno-unused-but-set-parameter -+ -Wno-unused-function -Wno-unused-parameter -Wno-sign-compare -Wno-deprecated - > - $<$:-Wno-varargs> - $<$:-Wno-unknown-warning-option> diff --git a/plugins/graph_algorithm/include/graph_algorithm/plugin_graph_algorithm.h b/plugins/graph_algorithm/include/graph_algorithm/plugin_graph_algorithm.h index acda4c074df..057894ffda3 100644 --- a/plugins/graph_algorithm/include/graph_algorithm/plugin_graph_algorithm.h +++ b/plugins/graph_algorithm/include/graph_algorithm/plugin_graph_algorithm.h @@ -140,6 +140,6 @@ namespace hal * @param[in] vertex_to_gate - map from node ID in igraph to HAL gate * @returns map from membership id to set of gates that have the membership. */ - std::map> get_memberships_for_hal(igraph_t* graph, igraph_vector_t membership, std::map vertex_to_gate); + std::map> get_memberships_for_hal(igraph_t* graph, igraph_vector_int_t *membership, std::map vertex_to_gate); }; -} // namespace hal \ No newline at end of file +} // namespace hal diff --git a/plugins/graph_algorithm/src/clustering/communities_fast_greedy.cpp b/plugins/graph_algorithm/src/clustering/communities_fast_greedy.cpp index 8e921d5ddbb..0aa441064bb 100644 --- a/plugins/graph_algorithm/src/clustering/communities_fast_greedy.cpp +++ b/plugins/graph_algorithm/src/clustering/communities_fast_greedy.cpp @@ -21,33 +21,29 @@ namespace hal igraph_t graph; std::map vertex_to_gate = get_igraph_directed(nl, &graph); - igraph_vector_t membership, modularity; + igraph_vector_int_t membership, modularity; igraph_matrix_t merges; igraph_to_undirected(&graph, IGRAPH_TO_UNDIRECTED_MUTUAL, 0); - igraph_vector_init(&membership, 1); - igraph_vector_init(&modularity, 1); - igraph_matrix_init(&merges, 1, 1); + igraph_vector_int_init(&membership, 1); igraph_community_fastgreedy(&graph, - 0, /* no weights */ - &merges, - &modularity, + nullptr, /* no weights */ + nullptr, + nullptr, &membership); // map back to HAL structures std::map> community_sets; - for (int i = 0; i < igraph_vector_size(&membership); i++) + for (igraph_integer_t i = 0; i < igraph_vector_int_size(&membership); i++) { - community_sets[(int)VECTOR(membership)[i]].insert(vertex_to_gate[i]); + community_sets[VECTOR(membership)[i]].insert(vertex_to_gate[i]); } //igraph_vector_destroy(&membership); igraph_destroy(&graph); - igraph_vector_destroy(&membership); - igraph_vector_destroy(&modularity); - igraph_matrix_destroy(&merges); + igraph_vector_int_destroy(&membership); return community_sets; } diff --git a/plugins/graph_algorithm/src/clustering/communities_spinglass.cpp b/plugins/graph_algorithm/src/clustering/communities_spinglass.cpp index 8fcc10afe65..461f05190df 100644 --- a/plugins/graph_algorithm/src/clustering/communities_spinglass.cpp +++ b/plugins/graph_algorithm/src/clustering/communities_spinglass.cpp @@ -26,18 +26,18 @@ namespace hal igraph_real_t modularity, temperature; - igraph_vector_t membership, csize; + igraph_vector_int_t membership, csize; - igraph_vector_init(&membership, 0); - igraph_vector_init(&csize, 0); + igraph_vector_int_init(&membership, 0); + igraph_vector_int_init(&csize, 0); igraph_community_spinglass(&graph, - 0, /* no weights */ + nullptr, /* no weights */ &modularity, &temperature, &membership, &csize, - (igraph_integer_t)spins, /* no of spins */ - 0, /* parallel update */ + spins, /* no of spins */ + false, /* parallel update */ 1.0, /* start temperature */ 0.01, /* stop temperature */ 0.99, /* cooling factor */ @@ -51,17 +51,17 @@ namespace hal log("\tTemperature: {}", temperature); log("\tCluster sizes: "); - for (long int i = 0; i < igraph_vector_size(&csize); i++) + for (igraph_integer_t i = 0; i < igraph_vector_int_size(&csize); i++) { log("\t\t{}", (long int)VECTOR(csize)[i]); } // map back to HAL structures - auto community_sets = get_memberships_for_hal(&graph, membership, vertex_to_gate); + auto community_sets = get_memberships_for_hal(&graph, &membership, vertex_to_gate); igraph_destroy(&graph); - igraph_vector_destroy(&membership); - igraph_vector_destroy(&csize); + igraph_vector_int_destroy(&membership); + igraph_vector_int_destroy(&csize); return community_sets; } diff --git a/plugins/graph_algorithm/src/clustering/community_detection.cpp b/plugins/graph_algorithm/src/clustering/community_detection.cpp index 88023ee33c7..b0b447de3ab 100644 --- a/plugins/graph_algorithm/src/clustering/community_detection.cpp +++ b/plugins/graph_algorithm/src/clustering/community_detection.cpp @@ -68,8 +68,8 @@ namespace hal } /* transform all nets to igraph_real_t */ - igraph_real_t* edges = new igraph_real_t[edge_counter]; - u32 edge_vertice_counter = 0; + igraph_integer_t* edges = new igraph_integer_t[edge_counter]; + u32 edge_vertex_counter = 0; for (auto net : nl->get_nets()) { assert(net->get_sources().size() == 1); @@ -83,40 +83,35 @@ namespace hal if (successor->get_gate() == nullptr) continue; auto successor_id = nl_igraph_id_match[successor->get_gate()->get_id()]; - edges[edge_vertice_counter++] = (igraph_real_t)predecessor_id; - edges[edge_vertice_counter++] = (igraph_real_t)successor_id; + edges[edge_vertex_counter++] = predecessor_id; + edges[edge_vertex_counter++] = successor_id; } } /* create and add edges to the graph */ igraph_t graph; - igraph_vector_t netlist_edges; - igraph_vector_init_copy(&netlist_edges, edges, edge_counter); + igraph_vector_int_t netlist_edges; + igraph_vector_int_init_array(&netlist_edges, edges, edge_counter); delete[] edges; igraph_create(&graph, &netlist_edges, nl->get_gates().size(), IGRAPH_UNDIRECTED); - igraph_vector_destroy(&netlist_edges); + igraph_vector_int_destroy(&netlist_edges); /* remove double edges */ igraph_simplify(&graph, true, false, 0); /* Louvain method without weights */ - igraph_vector_t membership, modularity; - igraph_matrix_t merges; - igraph_vector_init(&membership, 1); - igraph_vector_init(&modularity, 1); - igraph_matrix_init(&merges, 1, 1); - igraph_community_fastgreedy(&graph, nullptr, &merges, &modularity, &membership); - igraph_vector_destroy(&modularity); - igraph_matrix_destroy(&merges); + igraph_vector_int_t membership; + igraph_vector_int_init(&membership, 0); + igraph_community_fastgreedy(&graph, nullptr, nullptr, nullptr, &membership); igraph_destroy(&graph); /* group gates by community membership */ std::map> community_sets; - for (int i = 0; i < igraph_vector_size(&membership); i++) + for (igraph_integer_t i = 0; i < igraph_vector_int_size(&membership); i++) { - community_sets[(int)VECTOR(membership)[i]].insert(nl->get_gate_by_id(igraph_nl_id_match[i])); + community_sets[VECTOR(membership)[i]].insert(nl->get_gate_by_id(igraph_nl_id_match[i])); } - igraph_vector_destroy(&membership); + igraph_vector_int_destroy(&membership); return community_sets; } diff --git a/plugins/graph_algorithm/src/graph/strongly_connected_components.cpp b/plugins/graph_algorithm/src/graph/strongly_connected_components.cpp index e8aa9bd11d9..9ba0ed0088f 100644 --- a/plugins/graph_algorithm/src/graph/strongly_connected_components.cpp +++ b/plugins/graph_algorithm/src/graph/strongly_connected_components.cpp @@ -22,16 +22,15 @@ namespace hal igraph_t graph; std::map vertex_to_gate = get_igraph_directed(nl, &graph); - igraph_vector_t membership, csize; + igraph_vector_int_t membership; igraph_integer_t number_of_clusters; - igraph_vector_init(&membership, 0); - igraph_vector_init(&csize, 0); + igraph_vector_int_init(&membership, 0); // run scc - igraph_clusters(&graph, &membership, &csize, &number_of_clusters, IGRAPH_STRONG); + igraph_connected_components(&graph, &membership, nullptr, &number_of_clusters, IGRAPH_STRONG); // map back to HAL structures - std::map> ssc_membership = get_memberships_for_hal(&graph, membership, vertex_to_gate); + std::map> ssc_membership = get_memberships_for_hal(&graph, &membership, vertex_to_gate); // convert to set std::vector> sccs; @@ -47,8 +46,7 @@ namespace hal // cleanup igraph_destroy(&graph); - igraph_vector_destroy(&membership); - igraph_vector_destroy(&csize); + igraph_vector_int_destroy(&membership); return sccs; } diff --git a/plugins/graph_algorithm/src/igraph.cpp b/plugins/graph_algorithm/src/igraph.cpp index 9762dfa74fe..21ba4851db6 100644 --- a/plugins/graph_algorithm/src/igraph.cpp +++ b/plugins/graph_algorithm/src/igraph.cpp @@ -12,7 +12,6 @@ namespace hal { std::map GraphAlgorithmPlugin::get_igraph_directed(Netlist* const nl, igraph_t* graph) { - //igraph_t graph; // count all edges, remember in HAL one net(edge) has multiple sinks u32 edge_counter = 0; @@ -60,12 +59,12 @@ namespace hal log_debug("graph_algorithm", "nets: {}, edge_counter: {}", nl->get_nets().size(), edge_counter); // initialize edge vector - igraph_vector_t edges; - igraph_vector_init(&edges, 2 * edge_counter); + igraph_vector_int_t edges; + igraph_vector_int_init(&edges, 2 * edge_counter); // we need dummy gates for input/outputs u32 dummy_gate_counter = nl->get_gates().size() - 1; - u32 edge_vertice_counter = 0; + u32 edge_vertex_counter = 0; for (auto net : nl->get_nets()) { @@ -91,8 +90,8 @@ namespace hal u32 dummy_gate = ++dummy_gate_counter; for (const auto& dst_gate : dst_gates) { - VECTOR(edges)[edge_vertice_counter++] = dummy_gate; - VECTOR(edges)[edge_vertice_counter++] = dst_gate->get_id() - 1; + VECTOR(edges)[edge_vertex_counter++] = dummy_gate; + VECTOR(edges)[edge_vertex_counter++] = dst_gate->get_id() - 1; log_debug("graph_algorithm", "input_gate: {} --> {}: {}", dummy_gate, dst_gate->get_id() - 1, dst_gate->get_name().c_str()); } @@ -100,8 +99,8 @@ namespace hal // if gate has no dsts --> add dummy node else if (dst_gates.size() == 0) { - VECTOR(edges)[edge_vertice_counter++] = src_gate->get_id() - 1; - VECTOR(edges)[edge_vertice_counter++] = ++dummy_gate_counter; + VECTOR(edges)[edge_vertex_counter++] = src_gate->get_id() - 1; + VECTOR(edges)[edge_vertex_counter++] = ++dummy_gate_counter; log_debug("graph_algorithm", "{}: {} --> {} output\n", src_gate->get_name().c_str(), src_gate->get_id() - 1, dummy_gate_counter); } @@ -110,8 +109,8 @@ namespace hal { for (const auto& dst_gate : dst_gates) { - VECTOR(edges)[edge_vertice_counter++] = src_gate->get_id() - 1; - VECTOR(edges)[edge_vertice_counter++] = dst_gate->get_id() - 1; + VECTOR(edges)[edge_vertex_counter++] = src_gate->get_id() - 1; + VECTOR(edges)[edge_vertex_counter++] = dst_gate->get_id() - 1; log_debug("graph_algorithm", "{}: {} --> {}: {}", src_gate->get_name().c_str(), src_gate->get_id() - 1, dst_gate->get_id() - 1, dst_gate->get_name().c_str()); } @@ -119,18 +118,19 @@ namespace hal } igraph_create(graph, &edges, 0, IGRAPH_DIRECTED); + igraph_vector_int_destroy(&edges); // map with vertice id to hal-gate - std::map vertice_to_gate; + std::map vertex_to_gate; for (auto const& gate : nl->get_gates()) { - vertice_to_gate[gate->get_id() - 1] = gate; + vertex_to_gate[gate->get_id() - 1] = gate; } - return vertice_to_gate; + return vertex_to_gate; } - std::map> GraphAlgorithmPlugin::get_memberships_for_hal(igraph_t* graph, igraph_vector_t membership, std::map vertex_to_gate) + std::map> GraphAlgorithmPlugin::get_memberships_for_hal(igraph_t* graph, igraph_vector_int_t *membership, std::map vertex_to_gate) { // map back to HAL structures int vertices_num = (int)igraph_vcount(graph); @@ -141,7 +141,7 @@ namespace hal auto gate = vertex_to_gate[i]; if (gate == nullptr) continue; - community_sets[VECTOR(membership)[i]].insert(gate); + community_sets[VECTOR(*membership)[i]].insert(gate); } return community_sets; }