|
3 | 3 |
|
4 | 4 | print("=== Test 1: Import and version ===") |
5 | 5 | print(f"VieClus version: {vieclus.__version__}") |
6 | | -print(f"Mode constants: FAST={vieclus.FAST}, ECO={vieclus.ECO}, STRONG={vieclus.STRONG}") |
7 | 6 |
|
8 | 7 | print("\n=== Test 2: vieclus_graph helper class ===") |
9 | 8 | # Build a small graph with two clear communities: |
|
31 | 30 | print(f" num nodes: {g.num_nodes}") |
32 | 31 | print(f" num edges (directed): {len(adjncy)}") |
33 | 32 |
|
34 | | -print("\n=== Test 3: Clustering with FAST mode ===") |
| 33 | +print("\n=== Test 3: Clustering (two communities) ===") |
35 | 34 | modularity, clustering = vieclus.cluster( |
36 | 35 | vwgt, xadj, adjcwgt, adjncy, |
37 | 36 | suppress_output=False, |
38 | 37 | seed=0, |
39 | | - mode=vieclus.FAST, |
40 | 38 | time_limit=1.0 |
41 | 39 | ) |
42 | 40 | print(f" Modularity: {modularity:.6f}") |
|
47 | 45 | assert modularity > 0, f"Expected positive modularity, got {modularity}" |
48 | 46 | print(" PASSED") |
49 | 47 |
|
50 | | -print("\n=== Test 4: Clustering with ECO mode ===") |
| 48 | +print("\n=== Test 4: Clustering with different seed ===") |
51 | 49 | modularity, clustering = vieclus.cluster( |
52 | 50 | vwgt, xadj, adjcwgt, adjncy, |
53 | 51 | suppress_output=True, |
54 | 52 | seed=42, |
55 | | - mode=vieclus.ECO, |
56 | 53 | time_limit=1.0 |
57 | 54 | ) |
58 | 55 | print(f" Modularity: {modularity:.6f}") |
|
63 | 60 | assert modularity > 0 |
64 | 61 | print(" PASSED") |
65 | 62 |
|
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) ===") |
83 | 64 | # Simple path: 0-1-2-3-4 |
84 | 65 | xadj = [0, 1, 3, 5, 7, 8] |
85 | 66 | adjncy = [1, 0, 2, 1, 3, 2, 4, 3] |
|
90 | 71 | vwgt, xadj, adjcwgt, adjncy, |
91 | 72 | suppress_output=True, |
92 | 73 | seed=0, |
93 | | - mode=vieclus.ECO, |
94 | 74 | time_limit=1.0 |
95 | 75 | ) |
96 | 76 | print(f" Modularity: {modularity:.6f}") |
|
0 commit comments