示例#1
0
文件: build.py 项目: btanasoi/fvm
    def reorder_pkgs(self):
        ''' Sort packages so they are built in the correct order. '''
        deplist = []
        for pkg in self.packages:
            for dep in pkg.deps:
                if dep in self.packages:
                    deplist.append((dep, pkg))

        #print "PACKAGES=%s" % [p.name for p in self.packages]
        #print "DEPLIST=%s" % deplist
        self.packages = topological_sort(self.packages, deplist)
示例#2
0
文件: build.py 项目: wuhao1938/fvm
    def reorder_pkgs(self):
        ''' Sort packages so they are built in the correct order. '''
        deplist = []
        for pkg in self.packages:
            for dep in pkg.deps:
                if dep in self.packages:
                    deplist.append((dep, pkg))

        #print "PACKAGES=%s" % [p.name for p in self.packages]
        #print "DEPLIST=%s" % deplist
        self.packages = topological_sort(self.packages, deplist)
示例#3
0
    def test_tsort(self):

        g = """
          7,11
          7,8
          5,11
          3,8
          3,10
          8,10
          11,2
          11,9
          11,10
          8,9
          """
        edges = [tuple(map(int, e.split(","))) for e in g.strip().split("\n")]
        print edges
        assert topological_sort(edges) == [3, 5, 7, 8, 11, 2, 9, 10]

        self.assertRaises(GraphError, topological_sort, (edges + [(9, 3)]))