Documentation
¶
Overview ¶
Package graphutil contains utility functions for manipulating graphs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StronglyConnectedComponents ¶
func StronglyConnectedComponents[T comparable](nodes []T, successors func(T) []T) (sccs [][]T)
StronglyConnectedComponents is an implementation of Tarjan's strongly connected component (SCC) algorithm for generic nodes T. Successors returns a slice containing the targets of directed edges out from the given node. sccs is a slice of slices containing the nodes in each SCC. The order within the SCC is arbitrary. The order of SCCs is toposorted so that successors appear first; i.e. if the graph is a tree then in order from leaves towards the root. For summary-based bottom-up algorithms, the result is in the desired order to minimize recomputation.
Types ¶
Click to show internal directories.
Click to hide internal directories.