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
1 change: 0 additions & 1 deletion packages/cli/src/leiden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ pub fn leiden(
&mut rng,
use_modularity,
None,
None,
);

let leiden_completion_instant: Instant = Instant::now();
Expand Down
28 changes: 4 additions & 24 deletions packages/network_partitions/src/interop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,12 @@ mod tests {
let compact = CompactNetwork::from(nodes, neighbors, 0.0);

let mut rng1 = SmallRng::seed_from_u64(42);
let (_improved1, c1) = leiden(
&compact,
None,
Some(1),
None,
None,
&mut rng1,
true,
None,
None,
)
.unwrap();
let (_improved1, c1) =
leiden(&compact, None, Some(1), None, None, &mut rng1, true, None).unwrap();

let mut rng2 = SmallRng::seed_from_u64(42);
let (_improved2, c2) = leiden_view(
&compact,
None,
Some(1),
None,
None,
&mut rng2,
true,
Some(10),
None,
)
.unwrap();
let (_improved2, c2) =
leiden_view(&compact, None, Some(1), None, None, &mut rng2, true, None).unwrap();

// Both should find 2 communities
assert_eq!(c1.next_cluster_id(), 2);
Expand Down
44 changes: 6 additions & 38 deletions packages/network_partitions/src/interop/petgraph_interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ mod tests {
None,
&mut rng,
false,
Some(10),
None,
)
.unwrap();
Expand Down Expand Up @@ -471,18 +470,8 @@ mod tests {
let view = PetgraphNetworkView::new(&g).unwrap();
let mut rng = SmallRng::seed_from_u64(42);

let (_improved, clustering) = leiden_view(
&view,
None,
Some(2),
Some(0.5),
None,
&mut rng,
false,
Some(10),
None,
)
.unwrap();
let (_improved, clustering) =
leiden_view(&view, None, Some(2), Some(0.5), None, &mut rng, false, None).unwrap();

// improved flag depends on resolution and graph structure
// Should find 2 communities
Expand Down Expand Up @@ -536,7 +525,6 @@ mod tests {
None,
&mut rng,
false,
Some(10),
None,
)
.unwrap();
Expand Down Expand Up @@ -600,18 +588,8 @@ mod tests {
let view = PetgraphNetworkView::new(&g).unwrap();
let mut rng = SmallRng::seed_from_u64(123);

let (_, clustering) = leiden_view(
&view,
None,
Some(2),
Some(0.5),
None,
&mut rng,
false,
Some(10),
None,
)
.unwrap();
let (_, clustering) =
leiden_view(&view, None, Some(2), Some(0.5), None, &mut rng, false, None).unwrap();

// Should split into 2 communities
assert_eq!(
Expand Down Expand Up @@ -658,18 +636,8 @@ mod tests {
let view = PetgraphNetworkView::new(&g).unwrap();
let mut rng = SmallRng::seed_from_u64(42);

let (_, clustering) = leiden_view(
&view,
None,
Some(2),
Some(0.5),
None,
&mut rng,
false,
Some(10),
None,
)
.unwrap();
let (_, clustering) =
leiden_view(&view, None, Some(2), Some(0.5), None, &mut rng, false, None).unwrap();

// Each node should be in its own community (no reason to merge)
assert_eq!(clustering.num_nodes(), 3);
Expand Down
58 changes: 8 additions & 50 deletions packages/network_partitions/src/interop/sprs_interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,18 +361,8 @@ mod tests {
let view = SprsNetworkView::new(&mat).unwrap();
let mut rng = SmallRng::seed_from_u64(42);

let (_improved, clustering) = leiden_view(
&view,
None,
Some(2),
Some(0.5),
None,
&mut rng,
false,
Some(10),
None,
)
.unwrap();
let (_improved, clustering) =
leiden_view(&view, None, Some(2), Some(0.5), None, &mut rng, false, None).unwrap();

// improved flag depends on resolution and graph structure
let communities: std::collections::HashSet<usize> = (0..clustering.num_nodes())
Expand Down Expand Up @@ -404,18 +394,8 @@ mod tests {
let view = SprsNetworkView::new(&mat).unwrap();
let mut rng = SmallRng::seed_from_u64(42);

let (_improved, clustering) = leiden_view(
&view,
None,
Some(2),
Some(0.5),
None,
&mut rng,
false,
Some(10),
None,
)
.unwrap();
let (_improved, clustering) =
leiden_view(&view, None, Some(2), Some(0.5), None, &mut rng, false, None).unwrap();

// improved flag depends on resolution and graph structure
let communities: std::collections::HashSet<usize> = (0..clustering.num_nodes())
Expand Down Expand Up @@ -460,18 +440,8 @@ mod tests {
let view = SprsNetworkView::new(&mat).unwrap();
let mut rng = SmallRng::seed_from_u64(42);

let (_, clustering) = leiden_view(
&view,
None,
Some(2),
Some(0.5),
None,
&mut rng,
false,
Some(10),
None,
)
.unwrap();
let (_, clustering) =
leiden_view(&view, None, Some(2), Some(0.5), None, &mut rng, false, None).unwrap();

// Nodes 0 and 1 should be in the same community
assert_eq!(
Expand All @@ -487,18 +457,8 @@ mod tests {
let view = SprsNetworkView::new(&mat).unwrap();
let mut rng = SmallRng::seed_from_u64(42);

let (_, clustering) = leiden_view(
&view,
None,
Some(2),
Some(0.5),
None,
&mut rng,
false,
Some(10),
None,
)
.unwrap();
let (_, clustering) =
leiden_view(&view, None, Some(2), Some(0.5), None, &mut rng, false, None).unwrap();

// Each pair should form its own community
assert_eq!(
Expand Down Expand Up @@ -611,7 +571,6 @@ mod tests {
None,
&mut rng,
false,
Some(10),
None,
)
.unwrap();
Expand Down Expand Up @@ -639,7 +598,6 @@ mod tests {
None,
&mut rng,
false,
Some(10),
None,
)
.unwrap();
Expand Down
3 changes: 0 additions & 3 deletions packages/network_partitions/src/leiden/hierarchical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ pub fn hierarchical_leiden<T>(
rng: &mut T,
use_modularity: bool,
max_cluster_size: u32,
max_outer_iterations: Option<u32>,
max_local_moving_iterations: Option<u32>,
) -> Result<Vec<HierarchicalCluster>, CoreError>
where
Expand All @@ -139,7 +138,6 @@ where
randomness,
rng,
use_modularity,
max_outer_iterations,
max_local_moving_iterations,
)?;

Expand Down Expand Up @@ -174,7 +172,6 @@ where
randomness,
rng,
use_modularity,
max_outer_iterations,
max_local_moving_iterations,
)?;
let offset: usize = updated_clustering.next_cluster_id();
Expand Down
Loading
Loading