Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a33d47e
degree and betweenness
wuyazuholo Nov 16, 2025
f54a3dc
Merge branch 'pybind11' of github.com:wuyazuholo/Easy-Graph into pybi…
wuyazuholo Nov 16, 2025
f094fc4
betweenness
Nov 17, 2025
52df860
betweenness openmp
Nov 17, 2025
735e40e
betweenness
Nov 19, 2025
d587523
use binary heap
Nov 21, 2025
ae94632
Merge branch 'easy-graph:pybind11' into pybind11
wuyazuholo Nov 24, 2025
4feb23d
Merge branch 'easy-graph:pybind11' into pybind11
wuyazuholo Nov 28, 2025
90af1ad
omp
Dec 4, 2025
3989756
undirected graph
Dec 8, 2025
f92e549
GNN part
Dec 8, 2025
65c092d
change dim
Dec 8, 2025
4ecd1d4
add weight
Dec 15, 2025
2e36115
add float weight
Dec 15, 2025
4fbc25f
omp
Dec 17, 2025
fcf175b
eigenvector_centrality
Dec 18, 2025
448262d
add cpp_eigenvector
Dec 18, 2025
0038d9b
add eigenvector
Dec 18, 2025
185a9e7
add cpp_eigenvector
Dec 18, 2025
fe0eda3
dirtt flag
Dec 29, 2025
55a7bdc
normalize
Dec 29, 2025
6b76196
add omp
Jan 4, 2026
6880fcf
optimize constraint
Jan 8, 2026
8922fea
Merge branch 'easy-graph:pybind11' into pybind11
wuyazuholo Jan 9, 2026
4d248a9
add omp
Jan 10, 2026
fd63ce2
optimize pagerank
Jan 11, 2026
386f886
optimize pagerank
Jan 12, 2026
6bebe84
optimize effective_size
Jan 15, 2026
eab386a
optimize effective_size
Jan 16, 2026
a866663
optimize efficiency
Jan 22, 2026
5ac2447
support macOS
Jan 26, 2026
c4497b2
support macOS
Jan 26, 2026
164f6a4
support macOS
Jan 26, 2026
bf0770c
support macOS
Jan 26, 2026
f123f6d
Restore the original version
Jan 27, 2026
9245dec
modify intital weight
Jan 27, 2026
98c843c
support mac OS
Jan 28, 2026
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
10 changes: 3 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@ cmake_minimum_required(VERSION 3.23)

project(easygraph)

option(EASYGRAPH_ENABLE_OPENMP "Enable OpenMP acceleration (auto-detect)" ON)

option(EASYGRAPH_ENABLE_GPU "EASYGRAPH_ENABLE_GPU" OFF)

add_subdirectory(cpp_easygraph)

if (EASYGRAPH_ENABLE_GPU)

message("easygraph gpu module is enabled")

add_subdirectory(gpu_easygraph)

target_include_directories(cpp_easygraph
PRIVATE gpu_easygraph
)

else()

message("easygraph gpu module is disabled")

endif()
endif()
51 changes: 45 additions & 6 deletions cpp_easygraph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ file(GLOB SOURCES

add_subdirectory(pybind11)

option(EASYGRAPH_ENABLE_OPENMP "Enable OpenMP acceleration (auto-detect)" ON)
option(EASYGRAPH_ENABLE_GPU "EASYGRAPH_ENABLE_GPU" OFF)

if (EASYGRAPH_ENABLE_GPU)
Expand All @@ -22,7 +23,7 @@ if (EASYGRAPH_ENABLE_GPU)

set_property(TARGET cpp_easygraph PROPERTY CUDA_ARCHITECTURES all)

target_compile_definitions(cpp_easygraph
target_compile_definitions(cpp_easygraph
PRIVATE EASYGRAPH_ENABLE_GPU
)

Expand All @@ -31,14 +32,52 @@ if (EASYGRAPH_ENABLE_GPU)
)

else()

pybind11_add_module(cpp_easygraph
${SOURCES}
)

endif()

set_target_properties(cpp_easygraph PROPERTIES
LINK_SEARCH_START_STATIC ON
LINK_SEARCH_END_STATIC ON
)
if (EASYGRAPH_ENABLE_OPENMP)
if (APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
find_path(EG_LIBOMP_INCLUDE_DIR
NAMES omp.h
PATHS
/opt/homebrew/opt/libomp/include
/usr/local/opt/libomp/include
)

find_library(EG_LIBOMP_LIBRARY
NAMES omp libomp
PATHS
/opt/homebrew/opt/libomp/lib
/usr/local/opt/libomp/lib
)

if (EG_LIBOMP_INCLUDE_DIR AND EG_LIBOMP_LIBRARY)
message(STATUS "libomp found: ${EG_LIBOMP_LIBRARY}")

set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp" CACHE STRING "" FORCE)
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp" CACHE STRING "" FORCE)

set(OpenMP_CXX_INCLUDE_DIR "${EG_LIBOMP_INCLUDE_DIR}" CACHE PATH "" FORCE)
set(OpenMP_omp_LIBRARY "${EG_LIBOMP_LIBRARY}" CACHE FILEPATH "" FORCE)
else()
message(STATUS
"libomp not found on macOS. OpenMP will be disabled.\n"
"To enable OpenMP, run: brew install libomp"
)
endif()
endif()

find_package(OpenMP QUIET)
endif()

if (OpenMP_CXX_FOUND)
message(STATUS "OpenMP found, enabling parallel acceleration.")
target_link_libraries(cpp_easygraph PRIVATE OpenMP::OpenMP_CXX)
target_compile_definitions(cpp_easygraph PRIVATE EASYGRAPH_USE_OPENMP=1)
else()
message(STATUS "OpenMP not found, building in single-thread mode.")
target_compile_definitions(cpp_easygraph PRIVATE EASYGRAPH_USE_OPENMP=0)
endif()
6 changes: 5 additions & 1 deletion cpp_easygraph/cpp_easygraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,20 @@ PYBIND11_MODULE(cpp_easygraph, m) {
.def_property("pred", &DiGraph::get_pred,nullptr)
.def("generate_linkgraph", &DiGraph_generate_linkgraph,py::arg("weight") = "weight");

m.def("cpp_degree_centrality", &degree_centrality, py::arg("G"));
m.def("cpp_in_degree_centrality", &in_degree_centrality, py::arg("G"));
m.def("cpp_out_degree_centrality", &out_degree_centrality, py::arg("G"));
m.def("cpp_closeness_centrality", &closeness_centrality, py::arg("G"), py::arg("weight") = "weight", py::arg("cutoff") = py::none(), py::arg("sources") = py::none());
m.def("cpp_betweenness_centrality", &betweenness_centrality, py::arg("G"), py::arg("weight") = "weight", py::arg("cutoff") = py::none(),py::arg("sources") = py::none(), py::arg("normalized") = py::bool_(true), py::arg("endpoints") = py::bool_(false));
m.def("cpp_katz_centrality", &cpp_katz_centrality, py::arg("G"), py::arg("alpha") = 0.1, py::arg("beta") = 1.0, py::arg("max_iter") = 1000, py::arg("tol") = 1e-6, py::arg("normalized") = true);
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") = "weight");
m.def("cpp_k_core", &core_decomposition, py::arg("G"));
m.def("cpp_density", &density, py::arg("G"));
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_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_pagerank", &_pagerank, py::arg("G"), py::arg("alpha") = 0.85, py::arg("max_iterator") = 500, py::arg("threshold") = 1e-6, py::arg("weight") = "weight");
m.def("cpp_dijkstra_multisource", &_dijkstra_multisource, py::arg("G"), py::arg("sources"), py::arg("weight") = "weight", py::arg("target") = py::none());
m.def("cpp_spfa", &_spfa, py::arg("G"), py::arg("source"), py::arg("weight") = "weight");
m.def("cpp_clustering", &clustering, py::arg("G"), py::arg("nodes") = py::none(), py::arg("weight") = py::none());
Expand Down
Loading