Source code for graphbrain.backends.backend

[docs]class Backend(object): """Hypergraph low-level operations.""" def __init__(self): pass def close(self): raise NotImplementedError() def name(self): raise NotImplementedError()
[docs] def exists(self, vertex): """Checks if the given edge exists in the hypergraph.""" raise NotImplementedError()
[docs] def add(self, edge, timestamp=-1): """Adds an edges to the hypergraph if it does not exist yet.""" raise NotImplementedError()
[docs] def remove(self, edge): """Removes an edges from the hypergraph.""" raise NotImplementedError()
[docs] def pattern2edges(self, pattern, open_ended): """Return all the edges that match a pattern. A pattern is a collection of entity ids and wildcards (None).""" raise NotImplementedError()
[docs] def star(self, center): """Return all the edges that contain a given entity. Entity can be atomic or an edge.""" raise NotImplementedError()
[docs] def symbols_with_root(self, root): """Find all edge_symbols with the given root.""" raise NotImplementedError()
[docs] def edges_with_symbols(self, symbols, root=None): """Find all edges containing the given edge_symbols, and optionally a given root""" raise NotImplementedError()
[docs] def destroy(self): """Erase the hypergraph.""" raise NotImplementedError()
[docs] def set_attribute(self, vertex, attribute, value): """Sets the value of an attribute.""" raise NotImplementedError()
[docs] def inc_attribute(self, vertex, attribute): """Increments an attribute of a vertex.""" raise NotImplementedError()
[docs] def dec_attribute(self, vertex, attribute): """Decrements an attribute of a vertex.""" raise NotImplementedError()
[docs] def get_str_attribute(self, vertex, attribute, or_else=None): """Returns attribute as string.""" raise NotImplementedError()
[docs] def get_int_attribute(self, vertex, attribute, or_else=None): """Returns attribute as integer value.""" raise NotImplementedError()
[docs] def get_float_attribute(self, vertex, attribute, or_else=None): """Returns attribute as float value.""" raise NotImplementedError()
[docs] def degree(self, vertex): """Returns the degree of a vertex.""" raise NotImplementedError()
[docs] def timestamp(self, vertex): """Returns the timestamp of a vertex.""" raise NotImplementedError()
[docs] def all(self): """Returns a lazy sequence of all the vertices in the hypergraph.""" raise NotImplementedError()
[docs] def all_attributes(self): """Returns a lazy sequence with a tuple for each vertex in the hypergraph. The first element of the tuple is the vertex itself, the second is a dictionary of attribute values (as strings).""" raise NotImplementedError()
[docs] def symbol_count(self): """Total number of edge_symbols in the hypergraph""" raise NotImplementedError()
[docs] def edge_count(self): """Total number of edge in the hypergraph""" raise NotImplementedError()
[docs] def total_degree(self): """Total degree of the hypergraph""" raise NotImplementedError()