def add_edge(self, n1, n2=None): n1 = normalize_token(n1) n2 = normalize_token(n2) if n2 is None: if len(n1)==3: n1,n2,x=n1 else: n1,n2=n1 self.__rep.add_edge(self.__name, n1, n2)
def add_edge_attr(self, n1, n2, type, attr): n1 = normalize_token(n1) n2 = normalize_token(n2) attr = normalize_token(attr) self.__rep.add_edge_attr(self.__name, n1, n2, type, attr)
def has_edge(self, n1, n2=None): n1 = normalize_token(n1) n2 = normalize_token(n2) return self.__rep.exists_edge(self.__name, n1, n2)
def add_node_attr(self, n, type, attr): n = normalize_token(n) attr = normalize_token(attr) if attr: attr = normalize_token(attr) self.__rep.add_node_attr(self.__name, n, type, attr)
def del_node(self, n): n = normalize_token(n) self.__rep.delete_node(self.__name, n)
def push(self, n): n = normalize_token(n) self.__rep.push(self.__name, n)
def add_node(self, n): n = normalize_token(n) self.__rep.add_node(self.__name, n)
def has_node(self, n): n = normalize_token(n) return self.__rep.exists_node(self.__name, n)
def has_node_attr(self, n, type, attr): n = normalize_token(n) return self.__rep.exists_node_attr(self.__name, n, type, attr)
def edges(self, n=None): n = normalize_token(n) return self.__rep.get_edges(self.__name, n)
def edge_attrs(self, n1, n2=None): n1 = normalize_token(n1) n2 = normalize_token(n2) return self.__rep.get_edge_attrs(self.__name, n1, n2)
def node_attrs(self, n=None, type=None): n = normalize_token(n) return self.__rep.get_nodes_attrs(self.__name, n, type)
def __contains__(self, n): n = normalize_token(n) return self.__rep.exists_node(self.__name, n)
def unpop(self, n, type='LIFO'): n = normalize_token(n) return self.__rep.unpop(self.__name, n, type)
def del_edge(self, n1, n2=None): n1 = normalize_token(n1) n2 = normalize_token(n2) if n2 is None: n1,n2=n1 self.__rep.delete_edge(self.__name, n1, n2)
def has_edge_attr(self, n1, n2, type, attr): n1 = normalize_token(n1) n2 = normalize_token(n2) return self.__rep.exists_edge_attr(self.__name, n1, n2, type, attr)
def neighbors(self, n): n = normalize_token(n) for edge in self.__rep.get_edges(self.__name, n): yield edge[1]
def set_focus_node(self, node): self.__focus_node = normalize_token(node)