Source code for graphbrain.backends.null

from graphbrain.backends.backend import Backend


[docs]class Null(Backend): """Hypergraph low-level operations.""" def __init__(self): Backend.__init__(self) def close(self): pass def name(self): return 'Null hypergraph (does nothing, just for testing purposes)'
[docs] def exists(self, vertex): """Checks if the given edge exists in the hypergraph.""" return False
[docs] def add(self, edge, timestamp=-1): """Adds an edges to the hypergraph if it does not exist yet.""" return edge
[docs] def remove(self, edge): """Removes an edges from the hypergraph.""" pass
[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).""" return set()
[docs] def star(self, center, limit=None): """Return all the edges that contain a given entity. Entity can be atomic or an edge.""" return set()
[docs] def symbols_with_root(self, root): """Find all edge_symbols with the given root.""" return set()
[docs] def edges_with_symbols(self, symbols, root=None): """Find all edges containing the given edge_symbols, and optionally a given root""" return set()
[docs] def destroy(self): """Erase the hypergraph.""" pass
[docs] def set_attribute(self, vertex, attribute, value): """Sets the value of an attribute.""" return False
[docs] def inc_attribute(self, vertex, attribute): """Increments attribute of a vertex.""" return False
[docs] def dec_attribute(self, vertex, attribute): """Decrements attribute of a vertex.""" return False
[docs] def get_str_attribute(self, vertex, attribute, or_else=None): """Returns attribute as string.""" return or_else
[docs] def get_int_attribute(self, vertex, attribute, or_else=None): """Returns attribute as integer value.""" return or_else
[docs] def get_float_attribute(self, vertex, attribute, or_else=None): """Returns attribute as float value.""" return or_else
[docs] def degree(self, vertex): """Returns the degree of a vertex.""" return 0
[docs] def timestamp(self, vertex): """Returns the timestamp of a vertex.""" return -1
[docs] def all(self): """Returns a lazy sequence of all the vertices in the hypergraph.""" return []
[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).""" return []
[docs] def symbol_count(self): """Total number of edge_symbols in the hypergraph""" return 0
[docs] def edge_count(self): """Total number of edge in the hypergraph""" return 0
[docs] def total_degree(self): """Total degree of the hypergraph""" return 0