pub fn fluid_communities_result<N, E, Ix>(
graph: &Graph<N, E, Ix>,
num_communities: usize,
max_iterations: usize,
) -> CommunityResult<N>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 analyzenum_communities- Target number of communities to findmax_iterations- Maximum number of iterations
§Returns
- A
CommunityResultwith 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());
}