def test_known1(self):
     self.assertEqual(get_cycles({
         1: [2],
         2: [3],
         3: [1, 4],
         4: [3]
     }), [[1, 2, 3], [3, 4]])
Beispiel #2
0
 def close(self):
     """called before visiting project (i.e set of modules)"""
     # don't try to compute cycles if the associated message is disabled
     if self.linter.is_message_enabled('cyclic-import'):
         vertices = list(self.import_graph)
         for cycle in get_cycles(self.import_graph, vertices=vertices):
             self.add_message('cyclic-import', args=' -> '.join(cycle))
Beispiel #3
0
 def close(self):
     """called before visiting project (i.e set of modules)"""
     # don't try to compute cycles if the associated message is disabled
     if self.linter.is_message_enabled('cyclic-import'):
         vertices = list(self.import_graph)
         for cycle in get_cycles(self.import_graph, vertices=vertices):
             self.add_message('cyclic-import', args=' -> '.join(cycle))
Beispiel #4
0
from __future__ import print_function

try:
    rtype, = __args__
except ValueError:
    print(
        'USAGE: cubicweb-ctl shell <instance> detect_cycle.py -- <relation type>'
    )
    print()

graph = {}
for fromeid, toeid in rql('Any X,Y WHERE X %s Y' % rtype):
    graph.setdefault(fromeid, []).append(toeid)

from logilab.common.graph import get_cycles

for cycle in get_cycles(graph):
    print('cycle', '->'.join(str(n) for n in cycle))
 def test_known2(self):
     self.assertEqual(get_cycles({1: [2], 2: [3], 3: [0], 0: []}), [])
 def test_known0(self):
     self.assertEqual(get_cycles({1: [2], 2: [3], 3: [1]}), [[1, 2, 3]])
Beispiel #7
0
 def test_known2(self):
     self.assertEqual(get_cycles({1:[2], 2:[3], 3:[0], 0:[]}), [])
Beispiel #8
0
 def test_known1(self):
     self.assertEqual(get_cycles({1:[2], 2:[3], 3:[1, 4], 4:[3]}), [[1, 2, 3], [3, 4]])
Beispiel #9
0
 def test_known0(self):
     self.assertEqual(get_cycles({1:[2], 2:[3], 3:[1]}), [[1, 2, 3]])
Beispiel #10
0
 def close(self):
     """called before visiting project (i.e set of modules)"""
     # don't try to compute cycles if the associated message is disabled
     if self.linter.is_message_enabled("R0401"):
         for cycle in get_cycles(self.import_graph):
             self.add_message("R0401", args=" -> ".join(cycle))