def createFirstGraph(): g = Graph(8) # create nodes n1 = Node("a") n2 = Node("b") n3 = Node("c") n4 = Node("d") n5 = Node("e") n6 = Node("f") n7 = Node("g") n8 = Node("h") # Create connections # n1 n1.addAdjacent(n2) # n2 n2.addAdjacent(n1) n2.addAdjacent(n3) n2.addAdjacent(n4) # n3 n3.addAdjacent(n2) # n4 n4.addAdjacent(n2) n4.addAdjacent(n5) # n5 n5.addAdjacent(n4) n5.addAdjacent(n6) n5.addAdjacent(n7) # n6 n6.addAdjacent(n5) # n7 n7.addAdjacent(n5) n7.addAdjacent(n8) # n8 n8.addAdjacent(n7) nodes = [n1, n2, n3, n4, n5, n6, n7, n8] for n in nodes: g.addNode(n) return g
def create_second_graph(): g = Graph(12) # create nodes n1 = Node("a") n2 = Node("b") n3 = Node("c") n4 = Node("d") n5 = Node("e") n6 = Node("f") n7 = Node("g") n8 = Node("h") n9 = Node("i") n10 = Node("j") n11 = Node("k") n12 = Node("l") # create connections n1.addAdjacent(n2) #n1 n2.addAdjacent(n3) #n2 n3.addAdjacent(n4) #n3 n3.addAdjacent(n5) n3.addAdjacent(n6) n4.addAdjacent(n7) #n4 n5.addAdjacent(n8) #n5 n6.addAdjacent(n9) #n6 n8.addAdjacent(n11) #n8 n9.addAdjacent(n10) #n9 n11.addAdjacent(n12) #n11 # add nodes to graph nodes = [n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12] for n in nodes: g.addNode(n) return g