Ejemplo n.º 1
0
 def main(*argv):
     "Application program number 2."
     print Application2.main.__doc__
     print "Should be: dbfaceg."
     tree = Application2.buildTree("a", "g")
     Algorithms.breadthFirstTraversal(tree)
     return 0
Ejemplo n.º 2
0
    def main(*argv):
        "Application11 test program."
        print Application11.main.__doc__

        g = GraphAsMatrix(32)
        Application11.weightedGraphTest(g)

        g = GraphAsLists(32)
        Application11.weightedGraphTest(g)

        g = DigraphAsMatrix(32)
        Application11.weightedDigraphTest(g)

        g = DigraphAsLists(32)
        Application11.weightedDigraphTest(g)

        print "Critical path analysis."
        g = DigraphAsMatrix(10)
        for v in xrange(10):
            g.addVertex(v)
        g.addEdge(0, 1, 3)
        g.addEdge(1, 2, 1)
        g.addEdge(1, 3, 4)
        g.addEdge(2, 4, 0)
        g.addEdge(3, 4, 0)
        g.addEdge(4, 5, 1)
        g.addEdge(5, 6, 9)
        g.addEdge(5, 7, 5)
        g.addEdge(6, 8, 0)
        g.addEdge(7, 8, 0)
        g.addEdge(8, 9, 2)
        print g
        g = Algorithms.criticalPathAnalysis(g)
        print g
        return 0
Ejemplo n.º 3
0
 def main(*argv):
     "Application program number 5. (word counter)"
     print Application5.main.__doc__
     Algorithms.wordCounter(sys.stdin, sys.stdout)
     return 0
Ejemplo n.º 4
0
 def main(*argv):
     "Application program number 9. (equivalence classes)"
     print Application9.main.__doc__
     Algorithms.equivalenceClasses(sys.stdin, sys.stdout)
     return 0
Ejemplo n.º 5
0
 def main(*argv):
     "Application program number 1. (calculator)"
     print Application1.main.__doc__
     Algorithms.calculator(sys.stdin, sys.stdout)
     return 0
Ejemplo n.º 6
0
 def main(*argv):
     "Application program number 7. (translator)"
     print Application7.main.__doc__
     Algorithms.translate(file("dict.txt", "r"), sys.stdin, sys.stdout)
     return 0