Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 45 additions & 22 deletions cpp_easygraph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,55 @@ add_subdirectory(pybind11)

option(EASYGRAPH_ENABLE_GPU "EASYGRAPH_ENABLE_GPU" OFF)

if (EASYGRAPH_ENABLE_GPU)

pybind11_add_module(cpp_easygraph
${SOURCES}
$<TARGET_OBJECTS:gpu_easygraph>
)

set_property(TARGET cpp_easygraph PROPERTY CUDA_ARCHITECTURES all)
# Find OpenMP (optional)
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
message(STATUS "Found OpenMP: ${OpenMP_CXX_VERSION}")
else()
message(STATUS "OpenMP not found; continuing without OpenMP")
endif()

target_compile_definitions(cpp_easygraph
PRIVATE EASYGRAPH_ENABLE_GPU
)
# Find ARPACK (optional; do not fail if absent)
find_library(ARPACK_LIB NAMES arpack arpack_double)
if(ARPACK_LIB)
message(STATUS "Found ARPACK library: ${ARPACK_LIB}")
add_compile_definitions(HAVE_ARPACK=1)
else()
message(WARNING "ARPACK not found; ARPACK-based solvers will be disabled (fallback used).")
add_compile_definitions(HAVE_ARPACK=0)
endif()

target_link_libraries(cpp_easygraph
PRIVATE cudart_static
)
find_package(LAPACK REQUIRED)

# Find Eigen (optional). Change to REQUIRED if Eigen must be enforced.
find_package(Eigen3 QUIET)
if(Eigen3_FOUND)
message(STATUS "Found Eigen3: ${Eigen3_INCLUDE_DIRS}")
add_compile_definitions(HAVE_EIGEN=1)
else()
message(STATUS "Eigen3 not found; eigen-accelerated code will be disabled")
add_compile_definitions(HAVE_EIGEN=0)
endif()

pybind11_add_module(cpp_easygraph
${SOURCES}
)
# Link/include to cpp_easygraph only if the target exists.
# This avoids errors when the target is created elsewhere or later.
if(TARGET cpp_easygraph)
if(Eigen3_FOUND)
target_include_directories(cpp_easygraph PRIVATE ${Eigen3_INCLUDE_DIRS})
if(TARGET Eigen3::Eigen)
target_link_libraries(cpp_easygraph PRIVATE Eigen3::Eigen)
endif()
endif()

endif()
if(OpenMP_CXX_FOUND)
target_link_libraries(cpp_easygraph PRIVATE OpenMP::OpenMP_CXX)
endif()

set_target_properties(cpp_easygraph PROPERTIES
LINK_SEARCH_START_STATIC ON
LINK_SEARCH_END_STATIC ON
)
if(ARPACK_LIB)
target_link_libraries(cpp_easygraph PRIVATE ${ARPACK_LIB} LAPACK::LAPACK)
else()
target_link_libraries(cpp_easygraph PRIVATE LAPACK::LAPACK)
endif()
else()
message(STATUS "cpp_easygraph target not defined yet; optional libs will be linked after target creation.")
endif()
1 change: 1 addition & 0 deletions cpp_easygraph/cpp_easygraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ PYBIND11_MODULE(cpp_easygraph, m) {
m.def("cpp_constraint", &constraint, py::arg("G"), py::arg("nodes") = py::none(), py::arg("weight") = py::none(), py::arg("n_workers") = py::none());
m.def("cpp_effective_size", &effective_size, py::arg("G"), py::arg("nodes") = py::none(), py::arg("weight") = py::none(), py::arg("n_workers") = py::none());
m.def("cpp_efficiency", &efficiency, py::arg("G"), py::arg("nodes") = py::none(), py::arg("weight") = py::none(), py::arg("n_workers") = py::none());
m.def("cpp_eigenvector_centrality", &cpp_eigenvector_centrality, py::arg("G"), py::arg("max_iter") = 100, py::arg("tol") = 1.0e-6, py::arg("nstart") = py::none(), py::arg("weight") = py::none());
m.def("cpp_hierarchy", &hierarchy, py::arg("G"), py::arg("nodes") = py::none(), py::arg("weight") = py::none(), py::arg("n_workers") = py::none());
m.def("cpp_pagerank", &_pagerank, py::arg("G"), py::arg("alpha") = 0.85, py::arg("max_iterator") = 500, py::arg("threshold") = 1e-6);
m.def("cpp_dijkstra_multisource", &_dijkstra_multisource, py::arg("G"), py::arg("sources"), py::arg("weight") = "weight", py::arg("target") = py::none());
Expand Down
7 changes: 7 additions & 0 deletions cpp_easygraph/functions/centrality/centrality.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ py::object cpp_katz_centrality(
py::object py_max_iter,
py::object py_tol,
py::object py_normalized
);
py::object cpp_eigenvector_centrality(
py::object G,
py::object py_max_iter,
py::object py_tol,
py::object py_nstart,
py::object py_weight
);
Loading
Loading