def runTest(self): mg = MyGraph(dart_partitions=[[[1, 2, 3], [4, 5, 6], [ 7, 8, 9 ], [10, 11, 12]], [[1, 4], [2, 7], [3, 10], [5, 8], [6, 11], [9, 12]]]) mg = MyGraph(graphs.CompleteGraph(4).edges()) res = OrientedRotationSystem.from_mygraph(mg) self.assertEqual(len(res), 1)
def runTest(self): bqt = MyGraph(**self.data["bouquet"]) digon = MyGraph(**self.data["2-gon"]) tri = MyGraph(**self.data["3-gon"]) self.assertEqual(len(bqt.subgraph_find(digon)), 1) self.assertEqual(len(bqt.subgraph_find(tri)), 0) self.assertEqual(len(tri.subgraph_find(tri, first_match_only=False)), 6)
def runTest(self): g = MyGraph(**self.data["3-gon"]) h = MyGraph(**self.data["bouquet"]) self.collection.insert(g) self.collection.insert(h) self.collection.commit() coll = GraphCollection(self.fp) self.assertEqual(len(coll.data), 2)
def runTest(self): g = MyGraph(**self.data["3-gon"]) h = MyGraph(**self.data["bouquet"]) k = MyGraph(**self.data["digon"]) self.collection.insert(g) self.collection.insert(h) self.collection.insert(k) self.collection.insert(h) self.collection.insert(k) self.assertEqual(self.collection.pk, 6)
def runTest(self): g = MyGraph(**self.data["3-gon"]) h = MyGraph(**self.data["no labels"]) k = MyGraph(**self.data["digon"]) self.collection.insert(g) self.collection.insert(h) self.collection.insert(k) t = MyGraph(dart_partitions=[[[1, 2], [3, 4]], [[1, 3], [2, 4]]]) results = self.collection.get_isomorphs(t) self.assertEqual(len(results), 2) #embed() self.assertItemsEqual([r[0] for r in results], [2, 3])
def runTest(self): mg = MyGraph(**self.data["3-gon"]) sp = mg.one_extension(0, 2) self.assertItemsEqual(sp.vertex_partition().values(), [[1, 2], [3, 4], [5, 6, 7], [8, 9, 10]]) self.assertItemsEqual(sp.edge_partition().values(), [[2, 8], [9, 3], [10, 7], [4, 5], [6, 1]])
def runTest(self): g = MyGraph(**self.data["3-gon"]) h = MyGraph(**self.data["bouquet"]) k = MyGraph(**self.data["digon"]) self.collection.insert(g) self.collection.insert(h) self.collection.insert(k) self.collection.insert(h) self.collection.insert(k) results1 = self.collection.select(degree_sequence=[4, 2, 2]) self.assertEqual(len(results1), 2) results2 = self.collection.select(v=3) #embed() self.assertEqual(len(results2), 3)
def runTest(self): t1 = MyGraph(dart_partitions=[[[]], []]) t2 = MyGraph.extensions_of(t1) t3 = MyGraph.extensions_of(t2) self.assertEqual(len(t3), 2) t4 = MyGraph.extensions_of(t3) self.assertEqual(len(t4), 9)
def runTest(self): mg = MyGraph(**self.data["no labels"]) split = mg.digon_split(0, [2]) t = split.digon_split(3, [1]) self.assertEqual(len(t.edges()), 6) self.assertItemsEqual(mg.vertex_partition(), {0: [1, 2], 1: [3, 4]})
def runTest(self): g = graphs.CompleteBipartiteGraph(1, 5) g.allow_multiple_edges(True) g.add_edges([[0, 2], [0, 3], [0, 4], [0, 5], [1, 2]]) #embed() mg = MyGraph(g.edges()) res = OrientedRotationSystem.from_mygraph(mg) self.assertEqual(len(res), 0)
def runTest(self): mg = MyGraph(**self.data["digon"]) split = mg.digon_split("u", [], vertex_labels=("u_1", "u_2")) self.assertItemsEqual(split.vertex_partition(), { "u_1": [5, 7], "u_2": [1, 2, 6, 8], "v": [3, 4] })
def runTest(self): mg = MyGraph(**self.data["from graph"]) self.assertItemsEqual(mg.vertices(), [1, 2, 3]) self.assertItemsEqual(mg.edges(), [(1, 2, "e"), (2, 3, "f"), (3, 1, "g")]) self.assertItemsEqual(mg.darts, [1, 2, 3, 4, 5, 6]) self.assertEqual(mg.vertex_partition(), { 1: [1, 6], 2: [2, 3], 3: [4, 5] })
def runTest(self): graphs5 = GraphCollection('../graphs5.json') mg = MyGraph(dart_partitions=[ dict(z) for z in graphs5.select(id=20)[0]['dart_partitions'] ]) g_coll = GraphCollection('../graphs4.json') ors_coll = ORSCollection('../ors4.json') res = OrientedRotationSystem.inductive_from_mygraph( mg, g_coll, ors_coll) nonind = OrientedRotationSystem.from_mygraph(mg) self.assertEqual(len(res), len(nonind))
def runTest(self): g = graphs.CompleteGraph(5) g.delete_edge(0, 1) g.delete_edge(0, 2) mg = MyGraph(g.edges()) g_coll = GraphCollection('../graphs4.json') ors_coll = ORSCollection('../ors4.json') res = OrientedRotationSystem.inductive_from_mygraph( mg, g_coll, ors_coll) nonind = OrientedRotationSystem.from_mygraph(mg) self.assertEqual(len(res), len(nonind))
def get_isomorphs(self,g): """g should be an instance of MyGraph. Returns a list of tuples (id,mapping) where mapping is a dict mapping vertices of g to vertices of row id""" deg_seq = g.degree_sequence() l = self.select(degree_sequence=deg_seq) k = [(x['id'],MyGraph(dart_partitions=[dict(z) for z in x['dart_partitions']])) for x in l] out = [] for y in k: isos = y[1].isomorphisms(g) if len(isos) >0: out.append( (y[0],zip(g.vertices(),isos[0])) ) return out
def runTest(self): graphs4 = GraphCollection('../graphs4.json') self.assertEqual(len(graphs4.data), 9) results = [] count = 0 for row in graphs4.data: count += 1 g = MyGraph( dart_partitions=[dict(z) for z in row['dart_partitions']]) ir = OrientedRotationSystem.from_mygraph(g) results += ir ors4 = ORSCollection('../testors4.json') for r in results: ors4.insert(r[0], '../graphs4.json') ors4.commit() self.assertEqual(len(results), 9)
def runTest(self): graphs4 = GraphCollection('../graphs4.json') graphs5 = GraphCollection('../graphs5.json') ors4 = ORSCollection('../ors4.json') results = [] count = 0 for row in graphs5.data: print(count) count += 1 g = MyGraph( dart_partitions=[dict(z) for z in row['dart_partitions']]) ir = OrientedRotationSystem.inductive_from_mygraph( g, graphs4, ors4) results += ir ors5 = ORSCollection('../testors5.json') embed() for r in results: ors5.insert(r, '../graphs5.json') ors5.commit() self.assertEqual(len(results), 23)
def runTest(self): mg = MyGraph(**self.data["isolated vertex"]) self.assertItemsEqual(mg.vertices(), [0, 1]) self.assertItemsEqual(mg.edges(), [(0, 0, 0)])
def runTest(self): k = MyGraph(**self.data["3-gon"]) self.assertItemsEqual(k.find_divalent_vertex(), (0, 1, 2)) self.assertEqual(k.find_divalent_vertex()[0], 0)
def runTest(self): mg = MyGraph(**self.data["digon"]) self.assertItemsEqual(mg.vertices(), ['u', 'v']) self.assertItemsEqual(mg.edges(), [('u', 'v', 'e'), ('v', 'u', 'f')]) self.assertItemsEqual(mg.darts, [1, 2, 3, 4])
def runTest(self): mg = MyGraph(**self.data["no labels"]) self.assertItemsEqual(mg.vertices(), [0, 1]) self.assertItemsEqual(mg.edges(), [(0, 1, 0), (1, 0, 1)])
def runTest(self): mg = MyGraph(**self.data["partially labelled graph"]) self.assertItemsEqual(mg.edges(), [(1, 2, 10), (2, 1, 11)])
def runTest(self): tri = MyGraph(**self.data["3-gon"]) k4 = MyGraph(graphs.CompleteGraph(4)) self.assertEqual(len(k4.subgraph_find(tri, first_match_only=False)), 24)
def runTest(self): g = MyGraph(dart_partitions=[[(1, 2, 3), (4, )], [(1, 2), (3, 4)]]) self.assertDictEqual(g.vertex_partition(), {0: [1, 2, 3], 1: [4]})
def runTest(self): k = MyGraph(dart_partitions=[[[1, 2]], [[1, 2]]]) res = k.find_divalent_vertex() self.assertEqual(res, (0, 0, 0))
from sparsity import MyGraph from graphcollections import GraphCollection graphs6 = GraphCollection('graphs6.json') a = [ MyGraph(dart_partitions=[dict(z) for z in x['dart_partitions']]) for x in graphs6.data ] b = MyGraph.extensions_of(a, no_iso_check=True) raw7 = GraphCollection('raw7.json') for g in b: raw7.insert(g) raw7.commit()
def runTest(self): g = MyGraph(**self.data["digon"]) h = g.edge_deletion("f") self.assertDictEqual(h.edge_partition(), {"e": [1, 3]})
def runTest(self): k = MyGraph([[0, 1, 0], [0, 2, 1], [0, 3, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5]]) self.assertEqual(k.find_divalent_vertex(), None) l = k.edge_deletion(0) self.assertItemsEqual(l.find_divalent_vertex()[1:], (2, 3))
def mygraph(self): return MyGraph(dart_partitions=[{ min(x): list(x) for x in self.sigma_perm.cycle_tuples() }, self.tau_perm.cycle_tuples()])
def runTest(self): g = MyGraph([[0, 1, 0], [0, 2, 1], [0, 3, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5]]) h = g.vertex_deletion(0) k = MyGraph(**self.data["3-gon"]) self.assertEqual(len(h.isomorphisms(k)), 1)