This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The class `Vertex` is represents a vertex of a DAG that owns | |
| # references to its children. A topological ordering of a vertex `v` | |
| # and its children can be obtained by calling `v.toposort()` | |
| class Vertex: | |
| def __init__(self, name, children=None): | |
| self.name = name | |
| self.children = children or [] | |
| def toposort(self, visited=None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function print_progress_bar(i, n, t; length=20) | |
| pc = floor(Int, i/n*100) | |
| nbr = floor(Int, i/n*length) | |
| print('[', repeat("=", nbr), '>', | |
| repeat(" ", length-nbr), ']') | |
| print(" ($pc%)") | |
| rem = t*(n/i-1.0) | |
| print("\t") | |
| if rem < 60.0 | |
| print("$(ceil(Int, rem))s") |