class IsomorphTest(unittest.TestCase):

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

	def test_gi_01(self):
		self._graphs = loadgraphs('data\\basicgi2.grl')
		self.runTest(0, 1)
	def test_gi_02(self):
		self._graphs = loadgraphs('data\\basicgi2.grl')
		self.runTest(0, 2)
	def test_gi_03(self):
		self._graphs = loadgraphs('data\\basicgi2.grl')
		self.runTest(0, 3)
	def test_gi_12(self):
		self._graphs = loadgraphs('data\\basicgi2.grl')
		self.runTest(1, 2)
	def test_gi_13(self):
		self._graphs = loadgraphs('data\\basicgi2.grl')
		self.runTest(1, 3)
	def test_gi_23(self):
		self._graphs = loadgraphs('data\\basicgi2.grl')
		self.runTest(2, 3)

	def runTest(self, index1 : int, index2 : int):
		g1 = (self._graphs[0][index1])
		g2 = (self._graphs[0][index2])
		result = self._checker.isIsomorphic(copy.deepcopy(g1), copy.deepcopy(g2))
		print(result)
		writeDOT(g1, "data\\basicgi2_%s.dot"%(index1))
Example #2
0
class IsomorphTest(unittest.TestCase):
    def setUp(self):
        self._checker = IndividualizationRefinementChecker()

    def test_huge1_01(self):
        self._graphs = loadgraphs('data\colorref_largeexample_4_1026.grl')
        self.runTest(0, 1)

    def test_huge1_02(self):
        self._graphs = loadgraphs('data\colorref_largeexample_4_1026.grl')
        self.runTest(0, 2)

    def test_huge1_03(self):
        self._graphs = loadgraphs('data\colorref_largeexample_4_1026.grl')
        self.runTest(0, 3)

    def test_huge1_12(self):
        self._graphs = loadgraphs('data\colorref_largeexample_4_1026.grl')
        self.runTest(1, 2)

    def test_huge1_13(self):
        self._graphs = loadgraphs('data\colorref_largeexample_4_1026.grl')
        self.runTest(1, 3)

    def test_huge1_23(self):
        self._graphs = loadgraphs('data\colorref_largeexample_4_1026.grl')
        self.runTest(2, 3)

    def runTest(self, index1: int, index2: int):
        g1 = (self._graphs[0][index1])
        g2 = (self._graphs[0][index2])
        result = self._checker.isIsomorphic(g1, g2)
Example #3
0
class IsomorphTest(unittest.TestCase):
    def setUp(self):
        self._checker = IndividualizationRefinementChecker()

    def test_bigtrees1_01(self):
        self._graphs = loadgraphs("data\\bigtrees1.grl")
        self.runTest(0, 1, False)

    def test_bigtrees1_02(self):
        self._graphs = loadgraphs("data\\bigtrees1.grl")
        self.runTest(0, 2, True)

    def test_bigtrees1_03(self):
        self._graphs = loadgraphs("data\\bigtrees1.grl")
        self.runTest(0, 3, False)

    def test_bigtrees1_12(self):
        self._graphs = loadgraphs("data\\bigtrees1.grl")
        self.runTest(1, 2, False)

    def test_bigtrees1_13(self):
        self._graphs = loadgraphs("data\\bigtrees1.grl")
        self.runTest(1, 3, True)

    def test_bigtrees1_23(self):
        self._graphs = loadgraphs("data\\bigtrees1.grl")
        self.runTest(2, 3, False)

    def runTest(self, index1: int, index2: int, expectedResult: bool):
        g1 = (self._graphs[0][index1])
        g2 = (self._graphs[0][index2])
        result = self._checker.isIsomorphic(g1, g2)
        self.assertEqual(expectedResult, result)
Example #4
0
def run():
    checker = IndividualizationRefinementChecker()
    command = None
    chosen_coloring = False
    while not chosen_coloring:
        coloring = input(
            "Would you like to 1. Use normal Coloring or 2. Use fast Coloring")
        if coloring == "1":
            checker._checker = ColorRefinementChecker()
            chosen_coloring = True
        elif coloring == "2":
            checker._checker = FastPartitionRefinementChecker()
            chosen_coloring = True
        else:
            print("Please pick either 1 or 2")
    chosen_mode = False
    while not chosen_mode:
        mode = input(
            "Would you like to 1. Find an isomorphism or 2. Count the automorphisms"
        )
        if mode == "1":
            command = "isIsomorphic"
            chosen_mode = True
        elif mode == "2":
            command = "countIsomorphisms"
            chosen_mode = True
        else:
            print("Please pick either 1 or 2")
    stop = False
    while not stop:
        execute_file(command, checker)
        cont = input("Would you like to read another file? Y/N")
        if cont == "Y":
            stop = False
        elif cont == "N":
            stop = True
Example #5
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')
	def setUp(self):
		self._checker = IndividualizationRefinementChecker()
class IsomorphTest(unittest.TestCase):

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


	def test_Quick(self):
		self._graphs = loadgraphs('data\colorref_smallexample_4_7.grl')
		self.runTest(0, 1, False)
		self.runTest(0, 2, True)
		self.runTest(0, 3, False)
		self.runTest(1, 2, False)
		self.runTest(1, 3, True)
		self.runTest(2, 3, False)

	def test_Quick1(self):
		self._graphs = loadgraphs('data\colorref_smallexample_4_16.grl')
		self.runTest(0, 1, True)
		self.runTest(0, 2, False)
		self.runTest(0, 3, False)
		self.runTest(1, 2, False)
		self.runTest(1, 3, False)
		self.runTest(2, 3, True)

	def test_Quick3(self):
		self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
		self.runTest(0, 1, True)
		self.runTest(0, 2, False)
		self.runTest(0, 3, False)
		self.runTest(0, 4, False)
		self.runTest(0, 5, False)
		self.runTest(1, 2, False)
		self.runTest(1, 3, False)
		self.runTest(1, 4, False)
		self.runTest(1, 5, False)
		self.runTest(2, 3, True)
		self.runTest(2, 4, False)
		self.runTest(2, 5, False)
		self.runTest(3, 4, False)
		self.runTest(3, 5, False)
		self.runTest(4, 5, True)

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

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

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

	def runTest(self, index1: int, index2: int, expectedResult : bool):
		g1 = self._graphs[0][index1].clone()
		g2 = self._graphs[0][index2].clone()
		result = self._checker.isIsomorphic(g1, g2)
		print(index1, index2, result)
		self.assertEqual(expectedResult, result)
		if result:
			writeDOT(g1, 'cubes_' + str(index1) + '.dot')
			writeDOT(g2, 'cubes_' + str(index2) + '.dot')
 def setUp(self):
     self._checker = IndividualizationRefinementChecker()
     self._checker._checker = FastPartitionRefinementChecker()
class IsomorphTest(unittest.TestCase):
    def setUp(self):
        self._checker = IndividualizationRefinementChecker()
        self._checker._checker = FastPartitionRefinementChecker()

    def test_gi_01(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(0, 1)

    def test_gi_02(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(0, 2)

    def test_gi_03(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(0, 3)

    def test_gi_04(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(0, 4)

    def test_gi_05(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(0, 5)

    def test_gi_06(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(0, 6)

    def test_gi_12(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(1, 2)

    def test_gi_13(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(1, 3)

    def test_gi_14(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(1, 4)

    def test_gi_15(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(1, 5)

    def test_gi_16(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(1, 6)

    def test_gi_23(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(2, 3)

    def test_gi_24(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(2, 4)

    def test_gi_25(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(2, 5)

    def test_gi_26(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(2, 6)

    def test_gi_34(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(3, 4)

    def test_gi_35(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(3, 5)

    def test_gi_36(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(3, 6)

    def test_gi_45(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(4, 5)

    def test_gi_46(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(4, 6)

    def test_gi_56(self):
        self._graphs = loadgraphs('data\\modulesc.grl')
        self.runTest(5, 6)

    def runTest(self, index1: int, index2: int):
        g1 = (self._graphs[0][index1])
        g2 = (self._graphs[0][index2])
        result = self._checker.isIsomorphic(copy.deepcopy(g1),
                                            copy.deepcopy(g2))
        print(index1, index2, result)
        writeDOT(g1, "data\\basicgi2_%s.dot" % (index1))
class IsomorphTest(unittest.TestCase):
    def setUp(self):
        self._checker = IndividualizationRefinementChecker()

    def test_quick1_01(self):
        self._graphs = loadgraphs('data\colorref_smallexample_4_7.grl')
        self.runTest(0, 1, False)

    def test_quick1_02(self):
        self._graphs = loadgraphs('data\colorref_smallexample_4_7.grl')
        self.runTest(0, 2, True)

    def test_quick1_03(self):
        self._graphs = loadgraphs('data\colorref_smallexample_4_7.grl')
        self.runTest(0, 3, False)

    def test_quick1_12(self):
        self._graphs = loadgraphs('data\colorref_smallexample_4_7.grl')
        self.runTest(1, 2, False)

    def test_quick1_13(self):
        self._graphs = loadgraphs('data\colorref_smallexample_4_7.grl')
        self.runTest(1, 3, True)

    def test_quick1_23(self):
        self._graphs = loadgraphs('data\colorref_smallexample_4_7.grl')
        self.runTest(2, 3, False)

    def test_quick2_01(self):
        self._graphs = loadgraphs('data\colorref_smallexample_4_16.grl')
        self.runTest(0, 1, True)

    def test_quick2_02(self):
        self._graphs = loadgraphs('data\colorref_smallexample_4_16.grl')
        self.runTest(0, 2, False)

    def test_quick2_03(self):
        self._graphs = loadgraphs('data\colorref_smallexample_4_16.grl')
        self.runTest(0, 3, False)

    def test_quick2_12(self):
        self._graphs = loadgraphs('data\colorref_smallexample_4_16.grl')
        self.runTest(1, 2, False)

    def test_quick2_13(self):
        self._graphs = loadgraphs('data\colorref_smallexample_4_16.grl')
        self.runTest(1, 3, False)

    def test_quick2_23(self):
        self._graphs = loadgraphs('data\colorref_smallexample_4_16.grl')
        self.runTest(2, 3, True)

    def test_quick3_01(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(0, 1, True)

    def test_quick3_02(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(0, 2, False)

    def test_quick3_03(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(0, 3, False)

    def test_quick3_04(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(0, 4, False)

    def test_quick3_05(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(0, 5, False)

    def test_quick3_12(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(1, 2, False)

    def test_quick3_13(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(1, 3, False)

    def test_quick3_14(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(1, 4, False)

    def test_quick3_15(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(1, 5, False)

    def test_quick3_23(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(2, 3, True)

    def test_quick3_24(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(2, 4, False)

    def test_quick3_25(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(2, 5, False)

    def test_quick3_34(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(3, 4, False)

    def test_quick3_35(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(3, 5, False)

    def test_quick3_45(self):
        self._graphs = loadgraphs('data\colorref_smallexample_6_15.grl')
        self.runTest(4, 5, True)

    def test_quick4(self):
        self._graphs = loadgraphs('data\colorref_smallexample_2_49.grl')
        self.runTest(0, 1, True)

    def runTest(self, index1: int, index2: int, expectedResult: bool):
        g1 = (self._graphs[0][index1])
        g2 = (self._graphs[0][index2])
        result = self._checker.isIsomorphic(g1, g2)
        self.assertEqual(expectedResult, result)
Example #11
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]))
Example #12
0
 def setUp(self):
     self._checker = IndividualizationRefinementChecker()
     self._alphabet_jan = loadgraphs("alphabet_jan.grl")
     self._alphabet_tygo = loadgraphs("alphabet_tygo.grl")
     self._alphabet_pixel = loadgraphs("alphabet_pixel.grl")
Example #13
0
class SomeTest(unittest.TestCase):
    def setUp(self):
        self._checker = IndividualizationRefinementChecker()
        self._alphabet_jan = loadgraphs("alphabet_jan.grl")
        self._alphabet_tygo = loadgraphs("alphabet_tygo.grl")
        self._alphabet_pixel = loadgraphs("alphabet_pixel.grl")

    def test_jan(self):
        print("jan:")
        self.alpha_self(self._alphabet_jan)

    def test_pixel(self):
        print("pixel:")
        self.alpha_self(self._alphabet_pixel)

    def test_tygo(self):
        print("tygo:")
        self.alpha_self(self._alphabet_tygo)

    def test_jan_pixel_vs(self):
        print("jan vs pixel:")
        self.alpha_versus(self._alphabet_jan, self._alphabet_pixel)

    def test_jan_tygo_vs(self):
        print("jan vs tygo:")
        self.alpha_versus(self._alphabet_jan, self._alphabet_tygo)

    def test_pixel_tygo_vs(self):
        print("pixel vs tygo:")
        self.alpha_versus(self._alphabet_pixel, self._alphabet_tygo)

    def test_jan_pixel_all(self):
        print("jan and pixel:")
        self.alpha_all(self._alphabet_jan, self._alphabet_pixel)

    def test_jan_tygo_all(self):
        print("#jan and *tygo:")
        self.alpha_all(self._alphabet_jan, self._alphabet_tygo)

    def test_pixel_tygo_all(self):
        print("pixel and tygo:")
        self.alpha_all(self._alphabet_pixel, self._alphabet_tygo)

    def alpha_self(self, alpha: list):
        isos = []
        queue = list(range(0, 26))
        while (len(queue) > 0):
            index = queue.pop(0)
            localiso = []
            localiso.append(chr(index + 97))
            for i in range(index + 1, 26):

                g1 = copy.deepcopy(alpha[0][index])
                g2 = copy.deepcopy(alpha[0][i])
                if self._checker.isIsomorphic(g1, g2):
                    if i in queue:
                        queue.remove(i)
                    localiso.append(chr(i + 97))
            isos.append(localiso)
        print(isos)

    def alpha_versus(self, alpha1: list, alpha2: list):
        isos = []
        for i in range(0, 26):
            jan = copy.deepcopy(alpha1[0][i])
            tygo = copy.deepcopy(alpha2[0][i])
            iso = self._checker.isIsomorphic(jan, tygo)
            if iso:
                isos.append(chr(i + 97))
        print(isos)

    def alpha_all(self, alpha1: list, alpha2: list):
        alpha1 = copy.deepcopy(alpha1)
        alpha2 = copy.deepcopy(alpha2)
        for i in range(0, 26):
            alpha1[0][i]._label = "#%s" % chr(97 + i)
            alpha2[0][i]._label = "*%s" % chr(97 + i)
        mountain = list(alpha1[0]) + list(alpha2[0])
        isos = []
        while (len(mountain) > 0):
            g1 = mountain.pop(0)
            localiso = []
            localiso.append(g1._label)
            for g2 in mountain[:]:
                if self._checker.isIsomorphic(g1, g2):
                    mountain.remove(g2)
                    localiso.append(g2._label)
            isos.append(localiso)
        print(isos)