class mogwai.models.edge.Edge(outV, inV, **values)

Base class for all edges.

exception DoesNotExist

Object not found in database

exception Edge.MultipleObjectsReturned

Multiple objects returned on unique key lookup

exception Edge.WrongElementType

Unique lookup with key corresponding to vertex of different type

classmethod Edge.all(ids, as_dict=False)

Load all edges with the given edge_ids from the graph. By default this will return a list of edges but if as_dict is True then it will return a dictionary containing edge_ids as keys and edges found as values.

  • ids (list) – A list of titan IDs
  • as_dict (boolean) – Toggle whether to return a dictionary or list
Return type:

dict | list


Returns a map of column names to cleaned values

Return type:dict

Returns a map of property names to cleaned values containing only the properties which should be persisted on save.

Return type:dict
classmethod Edge.create(outV, inV, label=None, *args, **kwargs)

Create a new edge of the current type coming out of vertex outV and going into vertex inV with the given properties.

  • outV (Vertex) – The vertex the edge is coming out of
  • inV (Vertex) – The vertex the edge is going into

Delete the current edge from the graph.

classmethod Edge.deserialize(data)

Deserializes rexpro response into vertex or edge objects

classmethod Edge.find_by_value(field, value, as_dict=False)

Returns edges that match the given field/value pair.

  • field (str) – The field to search
  • value (str) – The value of the field
  • as_dict (boolean) – Return results as a dictionary
Return type:


classmethod Edge.get(id)

Look up edge by titan assigned ID. Raises a DoesNotExist exception if a edge with the given edge id was not found. Raises a MultipleObjectsReturned exception if the edge_id corresponds to more than one edge in the graph.

Parameters:id (str | basestring) – The titan assigned ID
Return type:mogwai.models.Edge
classmethod Edge.get_between(outV, inV, page_num=None, per_page=None)

Return all the edges with a given label between two vertices.

  • outV (Vertex) – The vertex the edge comes out of.
  • inV (Vertex) – The vertex the edge goes into.
  • page_num (int) – The page number of the results
  • per_page (int) – The number of results per page
Return type:


classmethod Edge.get_label()

Returns the label for this edge.

Return type:str
classmethod Edge.get_property_by_name(key)

Get’s the db_field_name of a property by key

Parameters:key (basestring | str) – attribute of the model
Return type:basestring | str | None
Edge.gremlin_path = 'edge.groovy'

Return the vertex that this edge goes into.

Return type:Vertex
Edge.label = None

Return the vertex that this edge is coming out of.

Return type:Vertex

Pre-save hook which is run before saving an element


Override this to perform pre-update validation


Reload the given element from the database.

Edge.save(*args, **kwargs)

Save this edge to the graph database.

classmethod Edge.translate_db_fields(data)

Translates field names from the database into field names used in our model

this is for cases where we’re saving a field under a different name than it’s model property

Parameters:data – dict
Return type:dict

performs an update of this element with the given values and returns the saved object


Perform validation of this edge raising a ValidationError if any problems are encountered.

Edge.validate_field(field_name, val)

Perform the validations associated with the field with the given name on the value passed.

  • field_name (str) – The name of property whose validations will be run
  • val (mixed) – The value to be validated
class mogwai.models.edge.EdgeMetaClass

Metaclass for edges.

mro() → list

return a type’s method resolution order