Top Level Namespace

Included Modules

Extended Modules

Defined in:

Method Summary

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).


[View source]