コード例 #1
0
 def rmttest_inherit_003(self):
     "Topological sort check"
     mg = create_test_graph_01()
     tsort = topological_sort(mg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == ['C', 'B', 'A'], \
         "incorrect topological sort"
コード例 #2
0
ファイル: test-topsort.py プロジェクト: oscarpicas/rmtoo
 def test_tsort_004(self):
     "More complex digraph"
     dg = Digraph( {"A": ["B", "C"], "B": ["C", "E"], "C": ["D", "E"],
                    "D": [], "E": [] } )
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['D', 'E', 'C', 'B', 'A'], "incorrect")
コード例 #3
0
ファイル: TestMygraph.py プロジェクト: CrypticGator/rmtoo
 def test_inherit_003(self):
     "Topological sort check"
     mg = create_test_graph_01()
     tsort = topological_sort(mg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['C', 'B', 'A'],
                      "incorrect topological sort")
コード例 #4
0
ファイル: oopricing1.py プロジェクト: vakaras/rmtoo-old
    def output_reqset(self, reqset, reqscont):

        # Because of a problem with the current OpenOffice versions,
        # there is the need to sometimes arrange requirements as rows
        # and sometimes as columns:
        # It is not possible to define the range of a list input as a
        # row: it must be a column.
        # The order dictionary holds the number - which can be
        # computed in a row or column.
        def create_reqs_index(srqes):
            sreqs_index = {}
            cnt = 0
            for req in sreqs:
                sreqs_index[req] = cnt
                cnt += 1
            return sreqs_index

        # The topological sort is needed.
        sreqs = topological_sort(self.topic_set.reqset)

        # Create the row / column index of each requirement
        self.sreqs_index = create_reqs_index(sreqs)

        # Create and save the document
        calcdoc = OpenDocumentSpreadsheet()
        self.create_meta(calcdoc, reqscont)
        self.create_styles(calcdoc)
        self.create_costs_sheet(calcdoc, sreqs)
        self.create_deps_sheet(calcdoc, sreqs)
        self.create_sums_sheet(calcdoc, sreqs)
        self.create_constants_sheet(calcdoc)
        self.create_result_sheet(calcdoc, sreqs)
        calcdoc.save(self.output_filename, True)
コード例 #5
0
ファイル: oopricing1.py プロジェクト: samjaninf/rmtoo
    def requirement_set_pre(self, requirement_set):
        '''The output of all the content.'''

        # Because of a problem with the current OpenOffice versions,
        # there is the need to sometimes arrange requirements as rows
        # and sometimes as columns:
        # It is not possible to define the range of a list input as a
        # row: it must be a column.
        # The order dictionary holds the number - which can be
        # computed in a row or column.
        def create_reqs_index(srqes):
            sreqs_index = {}
            cnt = 0
            for req in sreqs:
                sreqs_index[req] = cnt
                cnt += 1
            return sreqs_index

        sreqs = topological_sort(requirement_set)

        # Create the row / column index of each requirement
        self.sreqs_index = create_reqs_index(sreqs)

        # Create and save the document
        self.__create_costs_sheet(sreqs)
        self.__create_deps_sheet(sreqs)
        self.__create_sums_sheet(sreqs)
        self.__create_constants_sheet()
        self.__create_result_sheet(sreqs)
コード例 #6
0
ファイル: RMTTest-Mygraph.py プロジェクト: florath/rmtoo
 def rmttest_inherit_003(self):
     "Topological sort check"
     mg = create_test_graph_01()
     tsort = topological_sort(mg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == ['C', 'B', 'A'], \
         "incorrect topological sort"
コード例 #7
0
ファイル: TestTopsort.py プロジェクト: CrypticGator/rmtoo
 def test_tsort_005(self):
     "Digraph with two components"
     dg = digraph_create_from_dict( {"A": ["B", "C"], "B": ["C"], "C": [],
                    "D": ["E"], "E": [] } )
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['C', 'B', 'A', 'E', 'D'], "incorrect")
コード例 #8
0
ファイル: RDepConstraints.py プロジェクト: vakaras/rmtoo-old
 def unite_ce3s(self, reqset, ce3set):
     # The ce3s must be executed in topological order.
     ce3tsort = topological_sort(reqset)
     for r in ce3tsort:
         # Have a look for incoming nodes
         ince3s = []
         for i in r.outgoing:
             ince3s.append(ce3set.get(i.get_id()))
         lce3 = ce3set.get(r.get_id())
         lce3.unite(ince3s)
コード例 #9
0
ファイル: TopicSet.py プロジェクト: vakaras/rmtoo-old
 def cmad(self, reqscont, ofile):
     # Because the variables must be defined before they can be
     # accessed, the topological sort is needed here.
     tsort = topological_sort(self)
     for t in tsort:
         ofile.write("%s: %s.tic" % (self.create_makefile_name(t.name), os.path.join(self.topic_dir, t.name)))
         # Path the dependency handling of the requirements to the
         # Topic object itself.
         t.cmad(reqscont, ofile, self.name)
         ofile.write("\n")
コード例 #10
0
ファイル: RMTTest-Topsort.py プロジェクト: florath/rmtoo
    def rmttest_tsort_005(self):
        "Digraph with two components"
        dg = Digraph({"A": ["B", "C"], "B": ["C"], "C": [],
                      "D": ["E"], "E": []})
        tsort = topological_sort(dg)
        tnames = node_list_to_node_name_list(tsort)

        # There is no 'fixed' result - depending on the python
        # implementation different correct values are computed.
        assert self.__list_order(tnames, "B", "A")
        assert self.__list_order(tnames, "C", "A")
        assert self.__list_order(tnames, "E", "D")
コード例 #11
0
ファイル: TestTopsort.py プロジェクト: samjaninf/rmtoo
 def test_tsort_005(self):
     "Digraph with two components"
     dg = digraph_create_from_dict({
         "A": ["B", "C"],
         "B": ["C"],
         "C": [],
         "D": ["E"],
         "E": []
     })
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['C', 'B', 'A', 'E', 'D'], "incorrect")
コード例 #12
0
ファイル: TestTopsort.py プロジェクト: samjaninf/rmtoo
 def test_tsort_004(self):
     "More complex digraph"
     dg = digraph_create_from_dict({
         "A": ["B", "C"],
         "B": ["C", "E"],
         "C": ["D", "E"],
         "D": ["E"],
         "E": []
     })
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['E', 'D', 'C', 'B', 'A'], "incorrect")
コード例 #13
0
    def rmttest_tsort_005(self):
        "Digraph with two components"
        dg = Digraph({"A": ["B", "C"], "B": ["C"], "C": [],
                      "D": ["E"], "E": []})
        tsort = topological_sort(dg)
        tnames = node_list_to_node_name_list(tsort)

        # There is no 'fixed' result - depending on the python
        # implementation different correct values are computed.
        assert self.__list_order(tnames, "B", "A")
        assert self.__list_order(tnames, "C", "A")
        assert self.__list_order(tnames, "E", "D")
コード例 #14
0
 def __unite_ce3s(self):
     '''Execute the unification of the CE3s:
        From the list of all incoming nodes and the value of the
        current node compute the new value of the current node
        The ce3s must be executed in topological order.'''
     ce3tsort = topological_sort(self)
     for ce3node in ce3tsort:
         # Have a look for incoming nodes
         ince3s = []
         for i in ce3node.incoming:
             ince3s.append(self.__ce3set.get(i.get_id()))
         lce3 = self.__ce3set.get(ce3node.get_id())
         lce3.unite(ince3s)
コード例 #15
0
ファイル: RequirementSet.py プロジェクト: CrypticGator/rmtoo
 def __unite_ce3s(self):
     '''Execute the unification of the CE3s:
        From the list of all incoming nodes and the value of the 
        current node compute the new value of the current node
        The ce3s must be executed in topological order.'''
     ce3tsort = topological_sort(self)
     for r in ce3tsort:
         # TODO Outgoing
         # Have a look for incoming nodes
         ince3s = []
         for i in r.get_iter_incoming():
             ince3s.append(self.__ce3set.get(i.get_requirement().get_id()))
         lce3 = self.__ce3set.get(r.get_requirement().get_id())
         lce3.unite(ince3s)
コード例 #16
0
ファイル: RequirementSet.py プロジェクト: samjaninf/rmtoo
 def __unite_ce3s(self):
     '''Execute the unification of the CE3s:
        From the list of all incoming nodes and the value of the 
        current node compute the new value of the current node
        The ce3s must be executed in topological order.'''
     ce3tsort = topological_sort(self)
     for r in ce3tsort:
         # TODO Outgoing
         # Have a look for incoming nodes
         ince3s = []
         for i in r.get_iter_incoming():
             ince3s.append(self.__ce3set.get(i.get_requirement().get_id()))
         lce3 = self.__ce3set.get(r.get_requirement().get_id())
         lce3.unite(ince3s)
コード例 #17
0
 def rmttest_tsort_004(self):
     "More complex digraph"
     dg = Digraph({
         "A": ["B", "C"],
         "B": ["C", "E"],
         "C": ["D", "E"],
         "D": [],
         "E": []
     })
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     # There is no 'fixed' result - depending on the python
     # implementation different correct values are computed.
     self.assertTrue(self.__list_order(tnames, "D", "C"))
     self.assertTrue(self.__list_order(tnames, "E", "C"))
     self.assertTrue(self.__list_order(tnames, "E", "B"))
     self.assertTrue(self.__list_order(tnames, "C", "B"))
     self.assertTrue(self.__list_order(tnames, "C", "A"))
     self.assertTrue(self.__list_order(tnames, "B", "A"))
コード例 #18
0
ファイル: RMTTest-Topsort.py プロジェクト: florath/rmtoo
 def rmttest_tsort_001(self):
     "Simple three node digraph"
     dg = Digraph({"A": ["B", "C"], "B": ["C"], "C": []})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == ['C', 'B', 'A'], "incorrect"
コード例 #19
0
ファイル: TestTopsort.py プロジェクト: CrypticGator/rmtoo
 def test_tsort_002(self):
     "Zero node digraph"
     dg = digraph_create_from_dict( {} )
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, [], "incorrect")
コード例 #20
0
ファイル: TestTopsort.py プロジェクト: CrypticGator/rmtoo
 def test_tsort_003(self):
     "One node digraph"
     dg = digraph_create_from_dict( {"A": [] } )
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ["A"], "incorrect")
コード例 #21
0
ファイル: TestTopsort.py プロジェクト: samjaninf/rmtoo
 def test_tsort_001(self):
     "Simple three node digraph"
     dg = digraph_create_from_dict({"A": ["B", "C"], "B": ["C"], "C": []})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['C', 'B', 'A'], "incorrect")
コード例 #22
0
ファイル: TestTopsort.py プロジェクト: CrypticGator/rmtoo
 def test_tsort_001(self):
     "Simple three node digraph"
     dg = digraph_create_from_dict( {"A": ["B", "C"], "B": ["C"], "C": [] } )
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['C', 'B', 'A'], "incorrect")
コード例 #23
0
ファイル: InputModules.py プロジェクト: kown7/rmtoo
 def __topological_sort(self):
     '''Do a topological sort on the reqdeps modules.'''
     self.__reqdeps_sorted = topological_sort(self)
コード例 #24
0
ファイル: TestTopsort.py プロジェクト: samjaninf/rmtoo
 def test_tsort_002(self):
     "Zero node digraph"
     dg = digraph_create_from_dict({})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, [], "incorrect")
コード例 #25
0
 def rmttest_tsort_003(self):
     "One node digraph"
     dg = Digraph({"A": []})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == ["A"], "incorrect"
コード例 #26
0
ファイル: TestTopsort.py プロジェクト: samjaninf/rmtoo
 def test_tsort_003(self):
     "One node digraph"
     dg = digraph_create_from_dict({"A": []})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ["A"], "incorrect")
コード例 #27
0
 def rmttest_tsort_001(self):
     "Simple three node digraph"
     dg = Digraph({"A": ["B", "C"], "B": ["C"], "C": []})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == ['C', 'B', 'A'], "incorrect"
コード例 #28
0
 def rmttest_tsort_002(self):
     "Zero node digraph"
     dg = Digraph({})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == [], "incorrect"
コード例 #29
0
ファイル: Modules.py プロジェクト: vakaras/rmtoo-old
 def topological_sort(self):
     # Do a topoligical sort on the reqdeps modules.
     self.reqdeps_sorted = topological_sort(self)
コード例 #30
0
 def test_inherit_003(self):
     "Topological sort check"
     mg = create_test_graph_01()
     tsort = topological_sort(mg)
     tnames = node_list_to_node_name_list(tsort)
     self.assertEqual(tnames, ['C', 'B', 'A'], "incorrect topological sort")
コード例 #31
0
ファイル: InputModules.py プロジェクト: CrypticGator/rmtoo
 def __topological_sort(self):
     '''Do a topological sort on the reqdeps modules.'''
     self.__reqdeps_sorted = topological_sort(self)
コード例 #32
0
ファイル: RMTTest-Topsort.py プロジェクト: florath/rmtoo
 def rmttest_tsort_003(self):
     "One node digraph"
     dg = Digraph({"A": []})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == ["A"], "incorrect"
コード例 #33
0
ファイル: RMTTest-Topsort.py プロジェクト: florath/rmtoo
 def rmttest_tsort_002(self):
     "Zero node digraph"
     dg = Digraph({})
     tsort = topological_sort(dg)
     tnames = node_list_to_node_name_list(tsort)
     assert tnames == [], "incorrect"