getGroups method

VertexGroups<V, G> getGroups(
  1. Graph<V> graph
)

Implementation

VertexGroups<V, G> getGroups(Graph<V> graph) {
  VertexGroups<V, G> groups = {};
  for (final vertex in graph.vertices.values) {
    final g = assignGroup(vertex);

    for (final groupId in g) {
      final current = groups.valueOf(groupId, initialValue: {});
      current.add(vertex.id);
    }
  }
  return groups;
}