fluid_communities_result

Function fluid_communities_result 

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

Fluid communities algorithm with standardized CommunityResult return type

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

Fluid communities is a density-based algorithm where communities are formed by propagating “fluids” through the network. Each community starts with a seed node and expands by including neighboring nodes based on density.

§Arguments

  • graph - The graph to analyze
  • num_communities - Target number of communities to find
  • max_iterations - Maximum number of iterations

§Returns

  • A CommunityResult with comprehensive community information

§Time Complexity

O(k * m * c) where k is the number of iterations, m is the number of edges, and c is the target number of communities. Each iteration involves fluid propagation across all edges and community density calculations.

§Space Complexity

O(n + c) for storing node assignments, fluid densities per community, and tracking community membership changes.

§Example

use scirs2_graph::{Graph, fluid_communities_result};

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

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