示例#1
0
 def test_AddString(self):
     m = Matrix(2, 2)
     m.addString([1, 0])
     print(m.values)
     print(np.shape(m.values))
     self.assertEqual(1, np.shape(m.values)[0])
     self.assertEqual(2, np.shape(m.values)[1])
示例#2
0
 def test_Constructor(self):
     m = Matrix(2, 3)
     m.addString([1, 1, 1])
     m.addString([0, 1, 1])
     graph = Hasse(m)
     self.assertEqual(2, len(graph.builtNodes))
     self.assertEqual(3, len(graph.AllNodes))
示例#3
0
 def test_FindFacetInVertex2(self):
     m = Matrix(4, 3)
     m.addString([0, 1, 1])
     m.addString([1, 0, 1])
     m.addString([1, 0, 1])
     m.addString([0, 0, 1])
     self.assertTrue(m.findFacetInVertex(1, 0))
     self.assertTrue(m.findFacetInVertex(2, 3))
     self.assertFalse(m.findFacetInVertex(0, 0))
示例#4
0
 def test_VfromT(self):
     m = Matrix(4, 4)
     m.addString([1, 1, 1, 0])
     m.addString([0, 1, 1, 1])
     m.addString([1, 1, 1, 1])
     m.addString([1, 0, 1, 1])
     graph = Hasse(m)
     newSet = graph.VfromT([0, 3])
     self.assertEqual([2], newSet[0])
     self.assertEqual([3], newSet[1])
示例#5
0
 def test_ComputingNextLevelNodes(self):
     m = Matrix(4, 4)
     m.addString([1, 1, 0, 1])
     m.addString([0, 1, 1, 1])
     m.addString([1, 1, 1, 0])
     m.addString([1, 0, 1, 1])  # tetrahedra
     graph = Hasse(m)
     workNode = Node({0})
     newSet = graph.computingNextLevelNodes(workNode)
     self.assertEqual(3, len(newSet))
示例#6
0
 def test_Building(self):
     m = Matrix(4, 4)
     m.addString([1, 1, 0, 1])
     m.addString([0, 1, 1, 1])
     m.addString([1, 1, 1, 0])
     m.addString([1, 0, 1, 1])  # tetrahedra
     graph = Hasse(m)
     graph.building()
     graph.printGraph()
     self.assertEqual(16, graph.graphSize)
示例#7
0
 def test_FfromS(self):
     m = Matrix(4, 3)
     m.addString([1, 1, 1])
     m.addString([0, 1, 1])
     m.addString([1, 0, 1])
     m.addString([1, 0, 1])
     graph = Hasse(m)
     newSet = graph.FfromS([0, 2, 3])
     self.assertEqual([0], newSet[0])
     self.assertEqual([2], newSet[1])
示例#8
0
 def test_ConvertedVertexArray(self):
     m = Matrix(2, 3)
     m.addString([1, 1, 1])
     m.addString([0, 0, 1])
     m.convertedVertexArray()
     self.assertEqual(0, m.vertexInc[0])
     self.assertEqual(1, m.vertexInc[1])
     self.assertEqual(2, m.vertexInc[2])
     self.assertEqual(2, m.vertexInc[3])
     self.assertEqual(0, m.arrVertex[0])
     self.assertEqual(3, m.arrVertex[1])
示例#9
0
 def test_Closure(self):
     m = Matrix(4, 4)
     m.addString([1, 1, 1, 1])
     m.addString([0, 0, 1, 1])
     m.addString([1, 1, 0, 1])
     m.addString([1, 0, 1, 1])
     graph = Hasse(m)
     node = Node({0, 3})
     expectedNode = Node({0, 2, 3})
     newNode = graph.closure(node, 2)
     self.assertSetEqual(expectedNode.getElements(), newNode.getElements())
示例#10
0
 def test_ConvertedFacetArray(self):
     m = Matrix(3, 2)
     m.addString([1, 0])
     m.addString([1, 0])
     m.addString([1, 1])
     m.convertedFacetArray()
     self.assertEqual(0, m.facetInc[0])
     self.assertEqual(1, m.facetInc[1])
     self.assertEqual(2, m.facetInc[2])
     self.assertEqual(2, m.facetInc[3])
     self.assertEqual(0, m.arrFacet[0])
     self.assertEqual(3, m.arrFacet[1])
示例#11
0
文件: main.py 项目: tgolov/Hasse
def experiment(dimension, nameFile, vertex, facet):

    m = Matrix(vertex, facet)
    f = open(nameFile, 'r')
    for line in f:
        m.addString(line)
    graph = Hasse(m)
    start = time.time()
    graph.building()
    finish = time.time()
    graph.printGraph()
    timeRun = finish - start
    return timeRun
示例#12
0
 def test_FindVertexInFacet2(self):
     m = Matrix(3, 3)
     m.addString([1, 0, 1])
     m.addString([0, 0, 1])
     m.addString([0, 1, 1])
     self.assertTrue(m.findVertexInFacet(0, 0))
     self.assertTrue(m.findVertexInFacet(0, 2))
     self.assertTrue(m.findVertexInFacet(1, 2))
     self.assertTrue(m.findVertexInFacet(2, 1))
     self.assertTrue(m.findVertexInFacet(2, 2))
     self.assertFalse(m.findVertexInFacet(0, 1))
     self.assertFalse(m.findVertexInFacet(1, 0))
     self.assertFalse(m.findVertexInFacet(1, 1))
     self.assertFalse(m.findVertexInFacet(2, 0))
示例#13
0
文件: main.py 项目: tgolov/Hasse
def experimentRandom(dimension, vertex, facet):
    m = Matrix(vertex, facet)
    adding = list()
    for i in range(vertex):
        adding.clear()
        for j in range(facet):
            adding.append(random.randint(0, 1))
        m.addString(adding)
    graph = Hasse(m)
    start = time.time()
    graph.building()
    finish = time.time()
    graph.printGraph()
    timeRun = finish - start
    return timeRun
示例#14
0
 def test_Building2(self):
     m = Matrix(7, 7)
     m.addString([0, 1, 1, 1, 1, 1, 1])
     m.addString([1, 1, 0, 0, 0, 0, 1])
     m.addString([1, 1, 1, 0, 0, 0, 0])
     m.addString([1, 0, 1, 1, 0, 0, 0])
     m.addString([1, 0, 0, 1, 1, 0, 0])
     m.addString([1, 0, 0, 0, 1, 1, 0])
     m.addString([1, 0, 0, 0, 0, 1, 1])  # piramide
     graph = Hasse(m)
     graph.building()
     graph.printGraph()
     self.assertEqual(28, graph.graphSize)
示例#15
0
 def test_AddTwoStrings(self):
     m = Matrix(2, 2)
     m.addString([1, 0])
     m.addString([0, 1])
     self.assertEqual(2, np.shape(m.values)[0])
     self.assertEqual(2, np.shape(m.values)[1])
示例#16
0
 def test_CountingIncedence(self):
     m = Matrix(2, 2)
     m.addString([1, 0])
     m.addString([0, 1])
     self.assertEqual(2, m.countingIncedence())
示例#17
0
 def test_CountingIncedenceError(self):
     m = Matrix(2, 3)
     m.addString([0, 2, 1])
     self.assertRaises(ValueError, m.countingIncedence())