func SortStabilized(g graph.Directed, order func([]graph.Node)) (sorted []graph.Node, err error) {
	if order == nil {
		order = lexical
	}
	sccs := tarjanSCCstabilized(g, order)
	return sortedFrom(sccs, order)
}
SortStabilized performs a topological sort of the directed graph g returning the 'from'
to 'to' sort order, or the order defined by the in place order sort function where there
is no unambiguous topological ordering. If a topological ordering is not possible, an
Unorderable error is returned listing cyclic components in g with each cyclic component's
members sorted by the provided order function. If order is nil, nodes are ordered lexically
by node ID. When an Unorderable error is returned, each cyclic component's topological
position within the sorted nodes is marked with a nil graph.Node.
package topo
import (
	"fmt"
	"sort"
	"gonum.org/v1/gonum/graph"
	"gonum.org/v1/gonum/graph/internal/ordered"
	"gonum.org/v1/gonum/graph/internal/set"
)
type Unorderable [][]graph.Node
func (e Unorderable) Error() string {
	const maxNodes = 10
	var n int
	for _, c := range e {
		n += len(c)
	}
	if n > maxNodes {
		return fmt.Sprintf("topo: no topological ordering: %d nodes in %d cyclic components", n, len(e))
	}
	return fmt.Sprintf("topo: no topological ordering: cyclic components: %v", [][]graph.Node(e))
}
func lexical(nodes []graph.Node) { sort.Sort(ordered.ByID(nodes)) }
func Sort(g graph.Directed) (sorted []graph.Node, err error) {
	sccs := TarjanSCC(g)
	return sortedFrom(sccs, lexical)
}