cplib/graph/topologicalsort.nim

This documentation is automatically generated by online-judge-tools/verification-helper

:warning: cplib/graph/topologicalsort.nim

Depends on

Required by

Code

when not declared CPLIB_GRAPH_TOPOLOGICALSORT:
    const CPLIB_GRAPH_TOPOLOGICALSORT* = 1
    import cplib/graph/graph
    proc topologicalsort*(G: DirectedGraph): seq[int] =
        var gin = newseq[int](len(G))
        for i in 0..<len(G):
            for (j, _) in G.to_and_cost(i):
                gin[j] += 1
        var stack: seq[int]
        for i in 0..<len(G):
            if gin[i] == 0:
                stack.add(i)
        while len(stack) != 0:
            var i = stack.pop()
            result.add(i)
            for j in G[i]:
                gin[j] -= 1
                if gin[j] == 0:
                    stack.add(j)
    proc isDAG*(G: DirectedGraph): bool = G.topologicalsort.len == G.len
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.12/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.local/lib/python3.12/site-packages/onlinejudge_verify/languages/nim.py", line 86, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page