Example #1
0
 def test_edge_by_vertices_n(self):
     check = False
     try:
         BaseGraphOps.edge_by_vertices(self.graph, self.n1, self.n3)
     except ValueError:
         check = True
     self.assertTrue(check)
Example #2
0
 def from_preds_to_edgeset(
     g: AbstractGraph, preds: Dict[str, Dict[str, str]]
 ) -> Dict[str, Set[AbstractEdge]]:
     """!
     \brief obtain the edge set implied by the predecessor array.
     """
     esets: Dict[str, Set[AbstractEdge]] = {}
     V = {v.id(): v for v in g.V}
     for u, forest in preds.copy().items():
         eset: Set[AbstractEdge] = set()
         for child, parent in forest.items():
             cnode = V[child]
             if parent is not None:
                 pnode = V[parent]
                 eset = eset.union(
                     BaseGraphOps.edge_by_vertices(
                         g, start=pnode, end=cnode
                     )
                 )
         esets[u] = eset
     return esets
Example #3
0
 def test_edge_by_vertices(self):
     e = BaseGraphOps.edge_by_vertices(self.graph, self.n2, self.n3)
     self.assertEqual(e, set([self.e2]))