Implementations

Graphs

class ruruki.graphs.Graph

In-memory graph database.

See IGraph for doco.

class ruruki.graphs.PersistentGraph(path, auto_create=True)

Persistent Graph database storing data to a file system.

See IGraph for doco.

Note

Verices and Edges ID’s are retained when the path is loaded.

path
   |_ vertices
   |     |_ constraints.json (file)
   |     |_ label
   |     |     |_ 0
   |     |        |_ properties.json (file)
   |     |        |_ in-edges
   |     |        |     |_ 0 -> ../../../../edges/label/0 (symlink)
   |     |        |_ out-edges
   |     |              |_
   |     |
   |     |_ label
   |     |    |_ 1
   |     |         |_ properties.json (file)
   |     |          |_ in-edges
   |     |          |     |_
   |     |          |_ out-edges
   |     |                |_ 0 -> ../../../../edges/label/0 (symlink)
   |
   |_ edges
         |_ label
               |
               |_0
                 |_ properties.json (file)
                 |_ head
                 |   |_ 0 -> ../../../vertices/0 (symlink)
                 |_ tail
                     |_ 1 -> ../../../vertices/1 (symlink)
Parameters:
  • path (str) – Path to ruruki graph data on disk.
  • auto_create (bool) – If True, then missing vertices or edges directories will be created.

Entities

class ruruki.entities.EntitySet(entities=None)

EntitySet used for storing, filtering, and iterating over IEntity objects.

Note

See IEntitySet for documenation.

Parameters:entities (Iterable of IEntity) – Entities being added to the set.
clear()

This is slow (creates N new iterators!) but effective.

discard(entity)

Remove a entity from the current set.

Parameters:entity (IEntity) – Entity to be removed from the set.
Raises:KeyError – KeyError is raised if the entity being discared does not exists in the set.
isdisjoint(other)

Return True if two sets have a null intersection.

pop()

Return the popped value. Raise KeyError if empty.

class ruruki.entities.Entity(label=None, **kwargs)

Base class for containing the common methods used for the other entities like vertices and edges.

Note

See IEntity for doco.

Parameters:
  • labelIEntity label.
  • kwargs (str`=value or :class:`dict) – Additional properties for the IEntity.
class ruruki.entities.Vertex(label=None, **kwargs)

Vertex/Node is the representation of a entity. It can be anything and contains properties for additional information.

Note

See IVertex for doco.

Parameters:
  • labelIEntity label.
  • kwargs (str`=value or :class:`dict) – Additional properties for the IEntity.
class ruruki.entities.PersistentVertex(*args, **kwargs)

Persistent Vertex behaves exactly the same as a Vertex but has an additional path attribute which is the disk location.

class ruruki.entities.Edge(head, label, tail, **kwargs)

Edge/Relationship is the representation of a relationship between two entities. A edge has properties for additional information.

Note

See IEdge for doco.

Parameters:
class ruruki.entities.PersistentEdge(*args, **kwargs)

Persistent Edge behaves exactly the same as a Edge but has an additional path attribute which is the disk location.