... (("a", "b", "c"), ("a", "c"))])
set_u = set(u)
set_v = set(v)
if set_u.isdisjoint(set_v):
raise ValueError("No sepset found between these two edges.")
super().add_edge(u, v)
After Change
import networkx as nx
if u in self.nodes() and v in self.nodes() and nx.has_path(self, u, v):
raise ValueError("Addition of edge between {u} and {v} forms a cycle breaking the "
"properties of Junction Tree".format(u=str(u), v=str(v)))