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
85 changes: 68 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ option(BUILD_MATLAB_BINDINGS "Build MATLAB bindings" OFF)
option(USE_ASAN "Enable address sanitizer" OFF)
option(USE_SYSTEM_EIGEN3 "Use system pre-installed Eigen" ON)
option(ENABLE_DIAGNOSTIC_PRINT "Enable printing of diagnostic messages" OFF)
option(WITH_PMC "Enable usage of pmc (GPL License - see notice)" OFF)

if (ENABLE_DIAGNOSTIC_PRINT)
message(STATUS "Enable printing of diagnostic messages.")
Expand All @@ -46,11 +47,34 @@ endif ()
# Dependencies
#
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
find_external_dependency("Eigen3" "Eigen3::Eigen" "${CMAKE_CURRENT_LIST_DIR}/cmake/DownloadEigen.cmake")
find_package(OpenMP QUIET REQUIRED)
robin_download_pmc()
robin_download_xenium()
add_subdirectory(${pmc_SOURCE_DIR} ${pmc_BINARY_DIR})
find_package(Eigen3)
if(NOT Eigen3_FOUND)
message(STATUS "Eigen3 not found. Downloading Eigen3.")
find_external_dependency("Eigen3" "Eigen3::Eigen" "${CMAKE_CURRENT_LIST_DIR}/cmake/DownloadEigen.cmake")
endif()

find_package(OpenMP REQUIRED)

# pmc
if(WITH_PMC)
message(WARNING "PMC is licensed under the GPL. Enabling WITH_PMC will cause the resulting 'robin' library to be licensed under the GPL.")
find_package(pmc QUIET)
if(NOT pmc_FOUND)
robin_download_pmc()
add_subdirectory(${pmc_SOURCE_DIR} ${pmc_BINARY_DIR})
endif()

endif()

find_package(xenium QUIET)
if(NOT xenium_FOUND)
message(STATUS "Xenium not found. Downloading Xenium.")
robin_download_xenium()
# Set the flag after downloading
set(XENIUM_DOWNLOADED TRUE)
else()
set(XENIUM_DOWNLOADED FALSE)
endif()

#
# Add robin target
Expand All @@ -63,19 +87,34 @@ file(GLOB

add_library(robin STATIC ${SOURCE_FILES})
add_library(robin::robin ALIAS robin)

if(WITH_PMC)
target_link_libraries(robin
PUBLIC Eigen3::Eigen
xenium
xenium
PRIVATE OpenMP::OpenMP_CXX
PRIVATE pmc)
target_compile_definitions(robin PRIVATE USE_PMC) # CHANGED THIS LINE
else()
target_link_libraries(robin
PUBLIC Eigen3::Eigen
xenium
PRIVATE OpenMP::OpenMP_CXX)
endif()

target_include_directories(
robin
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
${Eigen3_INCLUDE_DIRS}
${xenium_INCLUDE_DIRS}
)




if (USE_ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fPIC")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
Expand Down Expand Up @@ -111,13 +150,23 @@ export(
NAMESPACE robin::
)

install(
TARGETS xenium pmc
EXPORT robinTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
if(xenium_FOUND AND XENIUM_DOWNLOADED)
install(
TARGETS xenium
EXPORT robinTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()

if(WITH_PMC AND pmc_FOUND)
install(
TARGETS pmc
EXPORT robinTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()

install(
EXPORT robinTargets
Expand All @@ -135,10 +184,12 @@ install(

install(DIRECTORY include/robin DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# To set forcibly xeniumConfig.cmake
install(FILES cmake/xeniumConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/xenium
)
if(xenium_FOUND)
# To set forcibly xeniumConfig.cmake
install(FILES cmake/xeniumConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/xenium
)
endif()

export(PACKAGE robin)

Expand Down Expand Up @@ -175,4 +226,4 @@ message(STATUS "BUILD_DOCS: ${BUILD_DOCS}")
message(STATUS "BUILD_MATLAB_BINDINGS: ${BUILD_MATLAB_BINDINGS}")
message(STATUS "USE_ASAN: ${USE_ASAN}")
message(STATUS "ENABLE_DIAGNOSTIC_PRINT: ${ENABLE_DIAGNOSTIC_PRINT}")
message(STATUS "===============================================================")
message(STATUS "===============================================================")
12 changes: 6 additions & 6 deletions include/robin/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class CompGraphConstructor<Measurements, CompCheckFunc, 2>
std::queue<EdgeType> edge_buffer;

#pragma omp for
for (size_t k = 0; k < N * (N - 1) / 2; ++k) {
for (long k = 0; k < N * (N - 1) / 2; ++k) {
size_t i = k / N;
size_t j = k % N;
if (j <= i) {
Expand Down Expand Up @@ -293,7 +293,7 @@ class CompGraphConstructor<Measurements, CompCheckFunc, 2>

#pragma omp for
// visit each edge twice
for (size_t i = 0; i < N; ++i) {
for (long i = 0; i < N; ++i) {
for (size_t j = 0; j < N; ++j) {
subset_indices[0] = i;
subset_indices[1] = j;
Expand Down Expand Up @@ -332,7 +332,7 @@ class CompGraphConstructor<Measurements, CompCheckFunc, 2>

#pragma omp for
// for loop that goes through each (i,j) edge twice
for (size_t i = 0; i < N; ++i) {
for (long i = 0; i < N; ++i) {
for (size_t j = 0; j < N; ++j) {
subset_indices[0] = i;
subset_indices[1] = j;
Expand Down Expand Up @@ -366,7 +366,7 @@ class CompGraphConstructor<Measurements, CompCheckFunc, 2>

#pragma omp for
// for loop that goes through each (i,j) edge twice
for (size_t i = 0; i < N; ++i) {
for (long i = 0; i < N; ++i) {
for (size_t j = 0; j < N; ++j) {
subset_indices[0] = i;
subset_indices[1] = j;
Expand Down Expand Up @@ -411,7 +411,7 @@ class CompGraphConstructor<Measurements, CompCheckFunc, 2>
auto* subset_indices = new size_t[2];

#pragma omp for
for (size_t k = 0; k < N * (N - 1) / 2; ++k) {
for (long k = 0; k < N * (N - 1) / 2; ++k) {
size_t i = k / N;
size_t j = k % N;
if (j <= i) {
Expand Down Expand Up @@ -451,7 +451,7 @@ class CompGraphConstructor<Measurements, CompCheckFunc, 2>
auto* subset_indices = new size_t[2];

#pragma omp for
for (size_t k = 0; k < N * (N - 1) / 2; ++k) {
for (long k = 0; k < N * (N - 1) / 2; ++k) {
size_t i = k / N;
size_t j = k % N;
if (j <= i) {
Expand Down
3 changes: 2 additions & 1 deletion include/robin/graph_solvers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class KCoreDecompositionSolver {
size_t max_k_core_number_ = 0;
};

#ifdef USE_PMC
/**
* A facade to the Parallel Maximum Clique (PMC) library.
*
Expand Down Expand Up @@ -119,5 +120,5 @@ class MaxCliqueSolver {
private:
Params params_;
};

#endif
}
18 changes: 0 additions & 18 deletions include/robin/pkc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,6 @@ struct graph_t {
*/
void BZ_kCores(const IGraph& g, std::vector<size_t>* deg);

/**
* @brief K-core decomposition with parallel PKC. This is the non-optimized version.
* Each thread has its own queue -- parallel PKC_org for k-core decomposition
*
* @param g
* @param deg
*/
void PKC_original(const IGraph& g, size_t* deg);

/**
* @brief K-core decomposition with parallel PKC. This particular function is suitable for large
* graph, with optimization detailed in the original paper.
*
* @param g
* @param deg
*/
void PKC_optimized(const IGraph& g, size_t* deg);

/**
* @brief Interface with robin::Graph for K-core decomposition with parallel PKC.
* @param g
Expand Down
2 changes: 1 addition & 1 deletion include/robin/problems.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See LICENSE for the license information

#pragma once

#define M_PI 3.14159265358979323846 // pi
#define _USE_MATH_DEFINES

#include <cmath>
Expand Down
2 changes: 2 additions & 0 deletions include/robin/robin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ namespace robin {
//
enum class InlierGraphStructure {
MAX_CORE = 0,
#ifdef USE_PMC
MAX_CLIQUE = 1,
#endif
};

std::vector<size_t> FindInlierStructure(const IGraph* g, InlierGraphStructure graph_structure);
Expand Down
2 changes: 2 additions & 0 deletions src/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#include <omp.h>
#include <random>

#ifdef USE_PMC
#include <pmc/pmc.h>
#endif
#include <robin/graph.hpp>
#include <robin/pkc.hpp>

Expand Down
5 changes: 4 additions & 1 deletion src/graph_solvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
// Authors: Jingnan Shi, et al. (see THANKS for the full author list)
// See LICENSE for the license information

#ifdef USE_PMC
#include <pmc/pmc.h>
#endif
#include <robin/pkc.hpp>
#include <robin/graph_core.hpp>
#include <robin/graph_solvers.hpp>
Expand Down Expand Up @@ -56,6 +58,7 @@ std::vector<size_t> KCoreDecompositionSolver::GetKCore(const size_t& k) {
return k_core;
}

#ifdef USE_PMC
//
// Definitions for the MaxCliqueSolver class
//
Expand Down Expand Up @@ -154,5 +157,5 @@ std::vector<size_t> MaxCliqueSolver::FindMaxClique(const IGraph& graph) const {
vector<size_t> C_result(C.begin(), C.end());
return C_result;
}

#endif
}
Loading