Top Level Namespace
Included Modules
- Croupier
- Spec::Expectations
- Spec::Methods
Extended Modules
- Croupier
- Spec::Expectations
- Spec::Methods
Defined in:
Method Summary
-
topological_sort(g)
Sort the vertices of
g(an adjacency hash, vertex => the vertices it points at) starting from the "start" root, so every vertex comes after the vertices pointing at it.
Method Detail
def topological_sort(g)
#
Sort the vertices of g (an adjacency hash, vertex => the vertices it
points at) starting from the "start" root, so every vertex comes after
the vertices pointing at it.
Neighbors are visited in sorted order, so the order among independent
vertices is deterministic instead of following hash-table layout.
g[v]? tolerates plain hashes without a default block (and doesn't
mutate the graph by inserting missing keys on read).