def test180_tutte_cage_graph(self): """ Tutte 12-cage graph. """ g = nx.LCF_graph(126, [17, 27, -13, -59, -35, 35, -11, 13, -53\ , 53, -27, 21, 57, 11, -21, -57, 59, -17], 7) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) self.assertEqual( len(mate1), len(mate2) )
def test142_utility_graph(self): """ Larger utility graph from LCF notation. """ g = nx.LCF_graph(60, [3, -3], 3) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test142_utility_graph") self.assertEqual( len(mate1), len(mate2) )
def test025_barbell_graph(self): """ Very small barbell graph. """ g = nx.barbell_graph(9, 2) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate2, "test025_barbell_graph_edmonds") mate1 = mv.max_cardinality_matching( g ) self.assertEqual( len(mate1), len(mate2) )
def test103_lollipop_graph(self): """ Large lollipop graph. """ g = nx.lollipop_graph(17, 11) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test103_lollipop_graph") self.assertEqual( len(mate1), len(mate2) )
def test200_icosahedralgraph(self): """ Icosahedral graph. """ g = nx.icosahedral_graph() mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) #td.showGraph(g, mate1, "test200_icosahedralgraph") self.assertEqual( len(mate1), len(mate2) )
def test090_singlebloom(self): """ Single bloom, two edge extensions, case 1. """ g = nx.Graph() g.add_edges_from([(0,1),(1,2),(2,3),(3,4),(4,5),(5,1),(3,6)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) self.assertEqual( len(mate1), len(mate2) )
def test030_twoedges(self): """ Two edges. """ g = nx.Graph() g.add_edges_from([(0,1),(1,2)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) self.assertEqual( len(mate1), len(mate2) )
def test083_barabasi_albert_graph(self): """ Random graph using Barabasi-Albert preferential attachment model. """ g = nx.barabasi_albert_graph(100, 5) mate1 = mv.max_cardinality_matching(g) mate2 = nx.max_weight_matching(g, True) self.assertEqual(len(mate1), len(mate2))
def test040_threeedges(self): """ Three edges, linear. """ g = nx.Graph() g.add_edges_from([(0,1),(1,2),(2,3)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) self.assertEqual( len(mate1), len(mate2) )
def test170_bullgraph(self): """ Bull graph. """ g = nx.bull_graph() mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) #td.showGraph(g, mate1, "test170_bullgraph") self.assertEqual( len(mate1), len(mate2) )
def test190_octahedralgraph(self): """ Octahedral graph. """ g = nx.octahedral_graph() mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test190_octahedralgraph") self.assertEqual( len(mate1), len(mate2) )
def test050_linear(self): """ Multiple edges, linear. """ g = nx.Graph() g.add_edges_from([(0,1),(1,2),(2,3),(3,4),(4,5),(5,6)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) self.assertEqual( len(mate1), len(mate2) )
def test160_petersengraph(self): """ Petersen graph. """ g = nx.petersen_graph() mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test160_petersengraph") self.assertEqual( len(mate1), len(mate2) )
def test070_circle(self): """ Multiple edges, circle of even length. """ g = nx.Graph() g.add_edges_from([(0,1),(1,2),(2,3),(3,4),(4,5),(5,0)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) self.assertEqual( len(mate1), len(mate2) )
def test020_singleedge(self): """ Single edge. """ g = nx.Graph() g.add_edge(0,1) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) self.assertEqual( len(mate1), len(mate2) )
def test035_dense_gnm_random_graph(self): """ Larger random graph picked from set of all graphs with n nodes and m edges. """ g = nx.dense_gnm_random_graph(300, 10000) mate1 = mv.max_cardinality_matching(g) mate2 = nx.max_weight_matching(g, True) self.assertEqual(len(mate1), len(mate2))
def test142_doublebloom(self): """ Two blooms, connected together by one edge. """ g = nx.Graph() g.add_edges_from([(0,1),(1,2),(2,3),(3,4),(4,0),(3,6),(6,7),(7,8),(8,9),(9,10),(10,6)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test142_doublebloom") self.assertEqual( len(mate1), len(mate2) )
def test220_fruchtgraph(self): """ Frucht graph, smallest cubical graph. """ g = nx.frucht_graph() mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test220_fruchtgraph") td.showGraph(g, mate2, "test220_fruchtgraph_edmonds") self.assertEqual( len(mate1), len(mate2) )
def test149_doublebloom(self): """ Two blooms, one embedded, connected at their centers. """ g = nx.Graph() g.add_edges_from([(0,1),(1,2),(2,3),(4,6),(4,1),(3,4),(4,0),(3,7),(7,8),(8,9),(9,10),(10,3)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test149_doublebloom") self.assertEqual( len(mate1), len(mate2) )
def test145_doublebloom(self): """ Two blooms, with three vertices, connected by one edge. """ g = nx.Graph() g.add_edges_from([(0,1),(1,2),(2,0),(2,3),(3,4),(4,5),(5,3),(4,6),(6,7),(7,8),(8,6)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test145_doublebloom") self.assertEqual( len(mate1), len(mate2) )
def test120_singlebloom(self): """ Single bloom, three connected components. """ g = nx.Graph() g.add_edges_from([(0,1),(1,2),(2,3),(3,4),(4,5),(5,0),(3,1),(3,5)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test120_singlebloom") self.assertEqual( len(mate1), len(mate2) )
def test080_singlebloom(self): """ Single bloom, one edge extension. """ g = nx.Graph() g.add_edges_from([(0,1),(1,2),(2,3),(3,4),(4,5),(5,1)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test080_singlebloom") self.assertEqual( len(mate1), len(mate2) )
def test151_triplebloom(self): """ Three blooms, connected together with three bridges. """ g = nx.Graph() g.add_edges_from([(0,1),(1,2),(2,3),(3,4),(4,0),(3,5),(5,6),(15,11),(11,12),(12,13)\ ,(13,14),(14,15),(6,7),(7,8),(8,9),(9,10),(10,6),(5,15)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test151_triplebloom") self.assertEqual( len(mate1), len(mate2) )
def test146_doublebloom(self): """ Two blooms, one embedded inside the other, last example in paper. """ g = nx.Graph() g.add_edges_from([(0,2),(2,1),(2,5),(1,4),(1,3),(3,4),(4,5),(3,6),(6,7),(7,8),(7,10)\ ,(5,10),(8,9),(10,11),(9,11),(11,12),(12,13)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test146_doublebloom") self.assertEqual( len(mate1), len(mate2) )
def test240_disconnected_blooms(self): """ Two blooms, connected together by two edges with another disconnected bloom graph. """ g = nx.Graph() g.add_edges_from([(0,1),(1,2),(2,3),(3,4),(4,0),(3,5),(5,6),(6,7),(7,8),(8,9),(9,10)\ ,(10,6),(11,12),(12,13),(14,15),(15,11),(12,14),(13,14)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test240_disconnected_blooms") self.assertEqual( len(mate1), len(mate2) )
def test260_inter_blooms(self): """ Two blooms, connected together. """ g = nx.Graph() g.add_edges_from([(1,2),(2,3),(3,4),(4,5),(5,1),(5,6),(6,7),(4,6)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test260_inter_blooms") self.assertEqual( len(mate1), len(mate2) )
def test280_pentagon_graph(self): """ Two blooms, connected together. """ g = nx.Graph() g.add_edges_from([(1,2),(2,3),(1,3),(3,4),(3,5),(4,5),(5,6),(6,7),(5,7),(7,8),(8,9),(7,9), (9,10),(10,2),(2,9)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test280_pentagon_graph") self.assertEqual( len(mate1), len(mate2) )
def test271_grid_graph(self): """ Two blooms, connected together. """ g = nx.Graph() g.add_edges_from([(1,2),(2,3),(3,4),(5,6),(6,7),(7,8), (9,10),(10,11),(11,12),(13,14),(14,15),(15,16), (1,5),(5,9),(9,13),(2,6),(6,10),(10,14),(3,7),(7,11),(11,15),(4,8),(8,12),(12,16),(16,17),(13,18)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test271_Grid_Graphs") self.assertEqual( len(mate1), len(mate2) )
def test211_cubicgraph(self): """ Cubic graph with three connected blooms that is slightly different. """ g = nx.Graph() g.add_edges_from([(0,1),(0,2),(0,3),(1,2),(2,3),(1,4),(3,4),(4,5),(5,6),(5,7),(6,8)\ ,(6,9),(8,10),(9,10),(10,11),(11,8),(11,9),(7,12),(7,14),(12,13)\ ,(13,14),(15,13),(15,12),(15,14),(12,14),(1,3),(8,9)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test211_cubicgraph") td.showGraph(g, mate2, "test211_cubicgraph_edmonds") self.assertEqual( len(mate1), len(mate2) )
def test230_flowersnarkgraph(self): """ Flower snark J5, a flower snark with 20 vertices and 30 edges. """ g = nx.Graph() g.add_edges_from([(0,1),(1,2),(2,3),(3,4),(4,5),(5,6),(6,7),(7,8),(8,9),(9,10)\ ,(10,11),(11,12),(12,13),(13,14),(14,0),(15,16),(16,17),(17,18)\ ,(18,19),(19,15),(0,15),(1,11),(2,7),(3,16),(4,14),(5,10),(6,17)\ ,(8,13),(9,18),(12,19)]) mate1 = mv.max_cardinality_matching( g ) mate2 = nx.max_weight_matching( g, True ) td.showGraph(g, mate1, "test230_flowersnarkgraph") td.showGraph(g, mate2, "test230_flowersnarkgraph_edmonds") self.assertEqual( len(mate1), len(mate2) )