def test_new_subgraph(self): """ tests that after building a partitioned graph, all partitined vertices and partitioend edges are in existance :return: """ subvertices = list() subedges = list() for i in range(10): subvertices.append(PartitionedVertex(None, "")) for i in range(5): subedges.append(MultiCastPartitionedEdge(subvertices[0], subvertices[(i + 1)])) for i in range(5, 10): subedges.append(MultiCastPartitionedEdge( subvertices[5], subvertices[(i + 1) % 10])) subgraph = PartitionedGraph(subvertices=subvertices, subedges=subedges) outgoing = subgraph.outgoing_subedges_from_subvertex(subvertices[0]) for i in range(5): if subedges[i] not in outgoing: raise AssertionError( "subedges[" + str(i) + "] is not in outgoing and should be") for i in range(5, 10): if subedges[i] in outgoing: raise AssertionError( "subedges[" + str(i) + "] is in outgoing and shouldn't be") incoming = subgraph.incoming_subedges_from_subvertex(subvertices[0]) if subedges[9] not in incoming: raise AssertionError( "subedges[9] is not in incoming and should be") for i in range(9): if subedges[i] in incoming: raise AssertionError( "subedges[" + str(i) + "] is in incoming and shouldn't be") subvertices_from_subgraph = list(subgraph.subvertices) for subvert in subvertices_from_subgraph: self.assertIn(subvert, subvertices) subvedges_from_subgraph = list(subgraph.subedges) for subedge in subvedges_from_subgraph: self.assertIn(subedge, subedges)