Function pathfinding::separate_components [] [src]

pub fn separate_components<N>(
    groups: &[Vec<N>]
) -> (HashMap<N, usize>, Vec<usize>) where
    N: Clone + Hash + Eq

Separate components of a graph into closed sets.

  • groups is a set of group of vertices connected together. It is acceptable for a group to contain only one node. Empty groups receive special treatment (see below).

This function returns a pair containing:

  • A mapping from every vertex to its set identifier. The set identifiers are opaque and will not necessarily be compact. However, it is guaranteed that they will not be greater than the number of groups.
  • A mapping from every group to its set identifier, with the identifiers being the same ones as the ones in the previous mapping. Each group corresponds to the identifier at the same index, except for empty group whose identifier is set to std::usize::MAX.