Skip to content

Commit f77e762

Browse files
committed
implemented the compute_components_per_block function
added .envrc and shell.nix files to load the dependencies via nix and direnv added .direnv folder to .gitignore
1 parent 920fba5 commit f77e762

4 files changed

Lines changed: 57 additions & 1 deletion

File tree

.envrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
use nix
2+
clear

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ python/tests/unittest
4848
python/tests/*.so
4949
python/examples/*.so
5050
compile_commands.json
51+
.direnv

mt-kahypar/partition/connected_components/compute_components.cpp

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
namespace mt_kahypar {
3030
namespace connected_components {
3131

32+
using Bitset = mt_kahypar::ds::Bitset;
33+
3234
template<typename PartitionedHypergraph>
3335
void compute_components_per_block(const PartitionedHypergraph& phg,
3436
const Context& context,
@@ -38,7 +40,47 @@ void compute_components_per_block(const PartitionedHypergraph& phg,
3840
list.clear();
3941
}
4042

41-
// TODO: compute components and write components of block i to result[i]
43+
(void)context;
44+
45+
Bitset node_colored;
46+
node_colored.resize(phg.initialNumNodes());
47+
48+
std::queue<HypernodeID> node_queue;
49+
PartitionID current_partition;
50+
51+
for (const HypernodeID& hn : phg.nodes()) {
52+
if (node_colored.isSet((size_t) hn)) {
53+
continue;
54+
}
55+
56+
current_partition = phg.partID(hn);
57+
node_queue.push(hn);
58+
59+
ConnectedComponent cc = { };
60+
61+
while (node_queue.size() > 0) {
62+
HypernodeID current = node_queue.front();
63+
node_colored.set((size_t) current);
64+
cc.nodes.push_back(current);
65+
node_queue.pop();
66+
67+
for (const HyperedgeID& he : phg.incidentEdges(current)) {
68+
for (const HypernodeID& incident_hn : phg.pins(he)) {
69+
if (node_colored.isSet((size_t) incident_hn)) {
70+
continue;
71+
}
72+
73+
if (phg.partID(incident_hn) != current_partition) {
74+
continue;
75+
}
76+
77+
node_queue.push(incident_hn);
78+
}
79+
}
80+
}
81+
82+
result[current_partition].push_back(cc);
83+
}
4284
}
4385

4486

shell.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{ pkgs ? import <nixpkgs> {}}:
2+
pkgs.mkShell {
3+
packages = with pkgs; [
4+
libgcc
5+
onetbb
6+
hwloc
7+
cmake
8+
];
9+
10+
buildInputs = [ pkgs.bashInteractive ];
11+
}

0 commit comments

Comments
 (0)