label_propagation_result

Function label_propagation_result 

Source
pub fn label_propagation_result<N, E, Ix>(
    graph: &Graph<N, E, Ix>,
    max_iterations: usize,
) -> CommunityResult<N>
where N: Node + Clone + Hash + Eq + Debug, E: EdgeWeight, Ix: IndexType,
Expand description

Label propagation algorithm with standardized CommunityResult return type

This function provides the same functionality as label_propagation but returns a standardized CommunityResult type that provides multiple ways to access the community structure.

§Arguments

  • graph - The graph to analyze
  • max_iterations - Maximum number of iterations (default: 100)

§Returns

  • A CommunityResult with comprehensive community information

§Time Complexity

O(k * m) where k is the number of iterations and m is the number of edges. In practice, the algorithm usually converges in a few iterations.

§Space Complexity

O(n) for storing node labels and community assignments.

§Example

use scirs2_graph::{Graph, label_propagation_result};

let mut graph: Graph<i32, f64> = Graph::new();
// ... add nodes and edges ...
let result = label_propagation_result(&graph, 100);

println!("Found {} communities", result.num_communities);
for (i, community) in result.communities.iter().enumerate() {
    println!("Community {}: {} members", i, community.len());
}