Skip to content
Merged
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
12 changes: 6 additions & 6 deletions algo/src/function/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ set(_algo_function_sources
spanning_forest.cpp
)
if (ICEBUG_ENABLED)
# The gds_*.cpp sources include NetworKit + Arrow headers. Linking the imported targets to
# the object library propagates their compile flags + include dirs to it.
list(APPEND _algo_function_sources gds_csr_bridge.cpp gds_page_rank.cpp gds_node2vec.cpp
gds_louvain.cpp gds_leiden.cpp gds_ppr.cpp)
# gds_registry.cpp is the only translation unit including NetworKit + Arrow headers:
# one row per algorithm in the catalog table, no per-algorithm files. Linking the
# imported targets to the object library propagates their compile flags + include dirs.
list(APPEND _algo_function_sources gds_csr_bridge.cpp gds_registry.cpp)
endif ()

add_library(lbug_algo_function
Expand All @@ -23,8 +23,8 @@ add_library(lbug_algo_function

if (ICEBUG_ENABLED)
target_link_libraries(lbug_algo_function PRIVATE Arrow::arrow_shared OpenMP::OpenMP_CXX)
# ICEBUG_ENABLED is read by gds_page_rank.cpp via #ifdef to skip its body when icebug is off
# (defensive: source isn't compiled in that case, but matches the header-side guard).
# ICEBUG_ENABLED guards the registry TU's NetworKit/Arrow includes (defensive: the TU
# isn't compiled when icebug is off, but matches the header-side guard).
target_compile_definitions(lbug_algo_function PRIVATE ICEBUG_ENABLED)
else ()
# Other sources still use <omp.h> for parallel regions, so keep the OpenMP link — just drop Arrow.
Expand Down
53 changes: 53 additions & 0 deletions algo/src/function/gds_csr_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,58 @@ BridgeCSR buildUndirectedCSR(main::ClientContext* context, const std::string& gr
return {std::move(indptr), std::move(indices)};
}

// Scan one direction into CSR arrays: fwdneighbors -> out pair, bwd neighbors -> in pair.
// Per-row sort + unique coalesces parallel edges (the SIMPLE directed projection); self-loops
// are kept — they are real directed edges, unlike in the symmetrized undirected scan.
static std::pair<std::shared_ptr<arrow::UInt64Array>, std::shared_ptr<arrow::UInt64Array>>
scanDirectedCSR(table_id_t tableID, offset_t numNodes, Graph* graph, bool fwd) {
const auto nbrTables = graph->getRelInfos(tableID);
const auto nbrInfo = nbrTables[0];
const auto scanState = graph->prepareRelScan(*nbrInfo.relGroupEntry, nbrInfo.relTableID,
nbrInfo.dstTableID, {}, false /*randomLookup*/);
std::vector<std::vector<uint64_t>> adj(numNodes);
std::vector<offset_t> nbrs;
for (offset_t nodeId = 0; nodeId < numNodes; ++nodeId) {
nbrs.clear();
const nodeID_t nid = {nodeId, tableID};
if (fwd) {
for (auto chunk : graph->scanFwd(nid, *scanState)) {
chunk.forEach(
[&](auto neighbors, auto, auto i) { nbrs.push_back(neighbors[i].offset); });
}
} else {
for (auto chunk : graph->scanBwd(nid, *scanState)) {
chunk.forEach(
[&](auto neighbors, auto, auto i) { nbrs.push_back(neighbors[i].offset); });
}
}
std::sort(nbrs.begin(), nbrs.end());
nbrs.erase(std::unique(nbrs.begin(), nbrs.end()), nbrs.end());
adj[nodeId].reserve(nbrs.size());
for (const auto nbr : nbrs) {
adj[nodeId].push_back(static_cast<uint64_t>(nbr));
}
}
std::vector<uint64_t> flat;
flat.reserve(1024);
std::vector<uint64_t> indptr(numNodes + 1, 0);
for (offset_t i = 0; i < numNodes; ++i) {
flat.insert(flat.end(), adj[i].begin(), adj[i].end());
indptr[i + 1] = flat.size();
}
auto indptrArr =
toU64([&](offset_t i) { return static_cast<offset_t>(indptr[i]); }, numNodes + 1);
auto indicesArr = toU64([&](offset_t i) { return static_cast<offset_t>(flat[i]); },
static_cast<offset_t>(flat.size()));
return {std::move(indptrArr), std::move(indicesArr)};
}

DirectedBridgeCSR buildDirectedCSR(graph::Graph* graph, common::table_id_t tableID,
common::offset_t numNodes) {
auto [outIndptr, outIndices] = scanDirectedCSR(tableID, numNodes, graph, /*fwd=*/true);
auto [inIndptr, inIndices] = scanDirectedCSR(tableID, numNodes, graph, /*fwd=*/false);
return {std::move(outIndptr), std::move(outIndices), std::move(inIndptr), std::move(inIndices)};
}

} // namespace algo_extension
} // namespace lbug
100 changes: 0 additions & 100 deletions algo/src/function/gds_leiden.cpp

This file was deleted.

54 changes: 0 additions & 54 deletions algo/src/function/gds_louvain.cpp

This file was deleted.

Loading
Loading