Skip to content

Commit 511a996

Browse files
Remove mode parameter, always use STRONG configuration
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a48a3c8 commit 511a996

File tree

6 files changed

+12
-66
lines changed

6 files changed

+12
-66
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ g.add_undirected_edge(2, 3, 1) # weak bridge between two communities
8686
# Convert to CSR format and cluster
8787
vwgt, xadj, adjcwgt, adjncy = g.get_csr_arrays()
8888
modularity, clustering = vieclus.cluster(vwgt, xadj, adjcwgt, adjncy,
89-
mode=vieclus.STRONG, time_limit=1.0)
89+
time_limit=1.0)
9090

9191
print(f"Modularity: {modularity}")
9292
print(f"Clustering: {clustering}")
@@ -106,7 +106,6 @@ adjcwgt = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
106106
modularity, clustering = vieclus.cluster(vwgt, xadj, adjcwgt, adjncy,
107107
suppress_output=True,
108108
seed=0,
109-
mode=vieclus.ECO,
110109
time_limit=2.0)
111110

112111
print(f"Modularity: {modularity}")
@@ -125,7 +124,6 @@ The `vieclus.cluster` function takes the following arguments:
125124
| `adjncy` | list | *required* | CSR adjacency array (length m) |
126125
| `suppress_output` | bool | `True` | Suppress console output |
127126
| `seed` | int | `0` | Random seed |
128-
| `mode` | int | `STRONG` | Clustering mode: `vieclus.FAST`, `vieclus.ECO`, or `vieclus.STRONG` |
129127
| `time_limit` | float | `1.0` | Time limit in seconds |
130128
| `cluster_upperbound` | int | `0` | Max cluster size (0 = no limit) |
131129

@@ -137,7 +135,7 @@ Release Notes
137135
### v1.2
138136
- Added Python interface (`pip install vieclus`) with pybind11 bindings
139137
- Added `vieclus_graph` helper class for easy graph construction (same interface as KaHIP)
140-
- Added `vieclus.cluster()` function with FAST, ECO, and STRONG modes
138+
- Added `vieclus.cluster()` function
141139
- Added PyPI packaging with scikit-build-core
142140
- Added GitHub Actions CI and automated PyPI publishing
143141
- Added NOMPI compilation support

interface/vieclus_interface.cpp

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,6 @@
2727
#include <omp.h>
2828
#endif
2929

30-
static void internal_vieclus_set_configuration(configuration & cfg,
31-
PartitionConfig & config,
32-
int mode) {
33-
switch (mode) {
34-
case VIECLUS_FAST:
35-
cfg.fast(config);
36-
break;
37-
case VIECLUS_ECO:
38-
cfg.eco(config);
39-
break;
40-
case VIECLUS_STRONG:
41-
cfg.strong(config);
42-
break;
43-
default:
44-
cfg.eco(config);
45-
break;
46-
}
47-
}
48-
4930
static void internal_build_graph(int* n,
5031
int* vwgt,
5132
int* xadj,
@@ -69,7 +50,7 @@ static void internal_build_graph(int* n,
6950

7051
void vieclus_clustering(int* n, int* vwgt, int* xadj,
7152
int* adjcwgt, int* adjncy,
72-
bool suppress_output, int seed, int mode,
53+
bool suppress_output, int seed,
7354
double time_limit, int cluster_upperbound,
7455
double* modularity, int* num_clusters, int* clustering) {
7556

@@ -81,10 +62,10 @@ void vieclus_clustering(int* n, int* vwgt, int* xadj,
8162
omp_set_num_threads(1);
8263
#endif
8364

84-
// Configure
65+
// Configure (always use STRONG)
8566
PartitionConfig config;
8667
configuration cfg;
87-
internal_vieclus_set_configuration(cfg, config, mode);
68+
cfg.strong(config);
8869

8970
config.k = 1;
9071
config.seed = seed;

interface/vieclus_interface.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ extern "C"
1212
{
1313
#endif
1414

15-
const int VIECLUS_FAST = 0;
16-
const int VIECLUS_ECO = 1;
17-
const int VIECLUS_STRONG = 2;
18-
19-
// Graph clustering using VieClus.
15+
// Graph clustering using VieClus (always uses STRONG configuration).
2016
// Uses METIS CSR format (same as KaHIP).
2117
//
2218
// Input:
@@ -27,7 +23,6 @@ const int VIECLUS_STRONG = 2;
2723
// adjncy - CSR adjacency array (array of m ints)
2824
// suppress_output - if true, suppress console output
2925
// seed - random seed
30-
// mode - VIECLUS_FAST (0), VIECLUS_ECO (1), or VIECLUS_STRONG (2)
3126
// time_limit - time limit in seconds
3227
// cluster_upperbound - max cluster size (0 = no limit)
3328
//
@@ -37,7 +32,7 @@ const int VIECLUS_STRONG = 2;
3732
// clustering - cluster assignment array (array of n ints, must be pre-allocated)
3833
void vieclus_clustering(int* n, int* vwgt, int* xadj,
3934
int* adjcwgt, int* adjncy,
40-
bool suppress_output, int seed, int mode,
35+
bool suppress_output, int seed,
4136
double time_limit, int cluster_upperbound,
4237
double* modularity, int* num_clusters, int* clustering);
4338

misc/pymodule/vieclus.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pybind11::object wrap_vieclus(
1414
const pybind11::object &adjncy,
1515
bool suppress_output,
1616
int seed,
17-
int mode,
1817
double time_limit,
1918
int cluster_upperbound) {
2019
int n = pybind11::len(xadj) - 1;
@@ -38,7 +37,7 @@ pybind11::object wrap_vieclus(
3837

3938
vieclus_clustering(&n, &vwgtv[0], &xadjv[0],
4039
&adjwgtv[0], &adjncyv[0],
41-
suppress_output, seed, mode,
40+
suppress_output, seed,
4241
time_limit, cluster_upperbound,
4342
&modularity, &num_clusters, clustering);
4443

@@ -60,7 +59,6 @@ PYBIND11_MODULE(vieclus, m) {
6059
pybind11::arg("adjncy"),
6160
pybind11::arg("suppress_output") = true,
6261
pybind11::arg("seed") = 0,
63-
pybind11::arg("mode") = 2,
6462
pybind11::arg("time_limit") = 1.0,
6563
pybind11::arg("cluster_upperbound") = 0);
6664
}

python/vieclus/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
"Make sure the package is properly installed."
1818
) from e
1919

20-
# Clustering mode constants
21-
FAST = 0
22-
ECO = 1
23-
STRONG = 2
24-
25-
2620
class vieclus_graph:
2721
"""Graph class for constructing graphs and converting to CSR format for VieClus.
2822
@@ -87,4 +81,4 @@ def get_csr_arrays(self):
8781
return vwgt, xadj, adjcwgt, adjncy
8882

8983

90-
__all__ = ["cluster", "vieclus_graph", "__version__", "FAST", "ECO", "STRONG"]
84+
__all__ = ["cluster", "vieclus_graph", "__version__"]

test_vieclus.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
print("=== Test 1: Import and version ===")
55
print(f"VieClus version: {vieclus.__version__}")
6-
print(f"Mode constants: FAST={vieclus.FAST}, ECO={vieclus.ECO}, STRONG={vieclus.STRONG}")
76

87
print("\n=== Test 2: vieclus_graph helper class ===")
98
# Build a small graph with two clear communities:
@@ -31,12 +30,11 @@
3130
print(f" num nodes: {g.num_nodes}")
3231
print(f" num edges (directed): {len(adjncy)}")
3332

34-
print("\n=== Test 3: Clustering with FAST mode ===")
33+
print("\n=== Test 3: Clustering (two communities) ===")
3534
modularity, clustering = vieclus.cluster(
3635
vwgt, xadj, adjcwgt, adjncy,
3736
suppress_output=False,
3837
seed=0,
39-
mode=vieclus.FAST,
4038
time_limit=1.0
4139
)
4240
print(f" Modularity: {modularity:.6f}")
@@ -47,12 +45,11 @@
4745
assert modularity > 0, f"Expected positive modularity, got {modularity}"
4846
print(" PASSED")
4947

50-
print("\n=== Test 4: Clustering with ECO mode ===")
48+
print("\n=== Test 4: Clustering with different seed ===")
5149
modularity, clustering = vieclus.cluster(
5250
vwgt, xadj, adjcwgt, adjncy,
5351
suppress_output=True,
5452
seed=42,
55-
mode=vieclus.ECO,
5653
time_limit=1.0
5754
)
5855
print(f" Modularity: {modularity:.6f}")
@@ -63,23 +60,7 @@
6360
assert modularity > 0
6461
print(" PASSED")
6562

66-
print("\n=== Test 5: Clustering with STRONG mode ===")
67-
modularity, clustering = vieclus.cluster(
68-
vwgt, xadj, adjcwgt, adjncy,
69-
suppress_output=True,
70-
seed=0,
71-
mode=vieclus.STRONG,
72-
time_limit=1.0
73-
)
74-
print(f" Modularity: {modularity:.6f}")
75-
print(f" Clustering: {list(clustering)}")
76-
num_clusters = len(set(clustering))
77-
print(f" Number of clusters: {num_clusters}")
78-
assert len(clustering) == 6
79-
assert modularity > 0
80-
print(" PASSED")
81-
82-
print("\n=== Test 6: Raw CSR arrays (5-node path graph) ===")
63+
print("\n=== Test 5: Raw CSR arrays (5-node path graph) ===")
8364
# Simple path: 0-1-2-3-4
8465
xadj = [0, 1, 3, 5, 7, 8]
8566
adjncy = [1, 0, 2, 1, 3, 2, 4, 3]
@@ -90,7 +71,6 @@
9071
vwgt, xadj, adjcwgt, adjncy,
9172
suppress_output=True,
9273
seed=0,
93-
mode=vieclus.ECO,
9474
time_limit=1.0
9575
)
9676
print(f" Modularity: {modularity:.6f}")

0 commit comments

Comments
 (0)