Exemple #1
0
 def load_graph(self, id):
     graph = self.store.get_graph(id)
     self._graph = graph
     self._graph.g_id = id
     self._induction = InductionEngine(self._graph)
     self.update_current_graph.emit(self._graph.to_json())
gl = [18]

for n in gl:
    fin = open(
        'C:/Users/temp-admin/Desktop/ove/data/snarks_graph6/snark{}_cyc4.g6'.
        format(n), 'r')
    stri = fin.readline()
    num = 0
    while stri != "":
        num = num + 1
        print "New Graph: ", num
        vertices, edges = readGraph(list(stri))
        content = {"vertices": vertices, "edges": edges}
        g = MultiGraph.from_json(json.dumps(content))
        graph_name = "snark{}_cyc4_{}".format(n, num)
        engine = InductionEngine(g)
        engine.edge_coloring()

        i = 0
        found = False
        for i in range(0, 10, 1):
            if engine.bicycle_layout():
                found = True
                break
            engine.edge_coloring()
        print "found bicycle"
        engine.find_petersen_subdivision()

        stri = fin.readline()
Exemple #3
0
graph1.set_color(e_id, 30, 1)

##############################
elist = []

elist.append(graph1.add_edge(2, 17))
elist.append(graph1.add_edge(5, 20))
elist.append(graph1.add_edge(8, 23))
elist.append(graph1.add_edge(1, 15))
elist.append(graph1.add_edge(3, 14))
elist.append(graph1.add_edge(4, 13))
elist.append(graph1.add_edge(6, 12))
elist.append(graph1.add_edge(7, 11))
elist.append(graph1.add_edge(9, 10))
elist.append(graph1.add_edge(16, 30))
elist.append(graph1.add_edge(18, 29))
elist.append(graph1.add_edge(19, 28))
elist.append(graph1.add_edge(21, 27))
elist.append(graph1.add_edge(22, 26))
elist.append(graph1.add_edge(24, 25))

for x in elist:
    graph1.get_edge(x).color = 3

#failed_graph_DB.add_graph("graph1",graph1.to_json())
engine = InductionEngine(graph1)
if engine.bicycle_algorithm() == False:
    print("haha not resolved")
else:
    print("resolved")
Exemple #4
0
    def merge(cls, g1, g2):
        inspector1 = InductionEngine(g1)
        inspector2 = InductionEngine(g2)
        (face1, cycle1) = inspector1.find_girth()
        (face2, cycle2) = inspector2.find_girth()
        if len(face1) != len(face2):
            print "two face not of same kind"
            return None

        graph = MultiGraph()
        v_count = 1
        v1_map = {}
        v2_map = {}
        for u in g1.vertices:
            v1_map[u.id] = v_count
            graph.add_vertex(v_count)
            v_count += 1
        for u in g2.vertices:
            v2_map[u.id] = v_count
            graph.add_vertex(v_count)
            v_count += 1

        for edge in g1.edges:
            (a, b) = edge.get_endpoints()
            if a in cycle1 and b in cycle1:
                continue
            graph.add_edge(v1_map[a], v1_map[b])

        for edge in g2.edges:
            (a, b) = edge.get_endpoints()
            if a in cycle2 and b in cycle2:
                continue
            graph.add_edge(v2_map[a], v2_map[b])

        k = min(len(cycle1), len(cycle2))
        cycle1.append(cycle1[0])
        cycle2.append(cycle2[0])
        for i in xrange(k):
            x, y = tuple(map(v1_map.get, cycle1[i:i + 2]))
            u, v = tuple(map(v2_map.get, cycle2[i:i + 2]))
            p = v_count
            q = v_count + 1
            v_count += 2
            graph.add_vertex(p)
            graph.add_vertex(q)
            graph.add_edge(x, p)
            graph.add_edge(p, y)
            graph.add_edge(p, q)
            graph.add_edge(u, q)
            graph.add_edge(q, v)

        for i in xrange(k, len(cycle1) - 1):
            x, y = tuple(map(v1_map.get, cycle1[i:i + 2]))
            if graph.multiplicity(x, y) == 0:
                graph.add_edge(x, y)

        for i in xrange(k, len(cycle2) - 1):
            x, y = tuple(map(v2_map.get, cycle2[i:i + 2]))
            if graph.multiplicity(x, y) == 0:
                graph.add_edge(x, y)
        return graph