Esempio n. 1
0
class IsomorphCountTest(unittest.TestCase):

    def setUp(self):
        self._checker = IndividualizationRefinementChecker()

    def test_cubes(self):
        self._graphs = loadgraphs('data\cubes3.grl')
        self.runTest(0, 1, 0)
        self.runTest(0, 2, 48)
        self.runTest(0, 3, 0)
        self.runTest(1, 2, 0)
        self.runTest(1, 3, 16)
        self.runTest(2, 3, 0)

    def test_cubes2(self):
        self._graphs = loadgraphs('data\cubes4.grl')
        self.runTest(0, 1, 0)
        self.runTest(0, 2, 8)
        self.runTest(0, 3, 0)
        self.runTest(1, 2, 0)
        self.runTest(1, 3, 384)
        self.runTest(2, 3, 0)

    def test_cubes3(self):
        self._graphs = loadgraphs('data\cubes5.grl')
        self.runTest(0, 1, 3840)
        self.runTest(0, 2, 0)
        self.runTest(0, 3, 0)
        self.runTest(1, 2, 0)
        self.runTest(1, 3, 0)
        self.runTest(2, 3, 0)

    def test_torus(self):
        self._graphs = loadgraphs('data\\torus24.grl')
        self.runTest(0, 3, 96)
        self.runTest(1, 2, 96)

    def runTest(self, index1: int, index2: int, expectedResult : int):
        g1 = self._graphs[0][index1].clone()
        g2 = self._graphs[0][index2].clone()
        result = self._checker.countIsomorphisms(g1, g2)
        print(index1, index2, result)
        self.assertEqual(expectedResult, result)
        if result:
            writeDOT(g1, 'cubes_' + str(index1) + '.dot')
            writeDOT(g2, 'cubes_' + str(index2) + '.dot')
Esempio n. 2
0
from isomorphism.ColorRefinementChecker import ColorRefinementChecker
from graph.graphIO import loadgraph
from isomorphism.IndividualizationRefinementChecker import IndividualizationRefinementChecker

# L = loadgraphs('data\colorref_smallexample_4_7.grl')
# checker = ColorRefinementChecker()
# print(checker.isIsomorphic(L[0][0], L[0][1]))
# print(checker.isIsomorphic(L[0][0], L[0][2]))
# print(checker.isIsomorphic(L[0][0], L[0][3]))

L = loadgraph('data\\basicAut1.gr')
checker = IndividualizationRefinementChecker()
print(checker.countIsomorphisms(L[0], L[0]))
#print(checker.countIsomorphisms(L[0][1], L[0][2]))
#L = loadgraphs('data\\trees90.grl')
#print(checker.countIsomorphisms(L[0][0], L[0][3]))
#print(checker.countIsomorphisms(L[0][1], L[0][2]))