Graph Functions

Definition of examples

For many of the following functions examples can be passed in as a parameter.
Examples are used to filter the result set for objects that match the conditions.
These examples can have the following values:

null, there is no matching executed all found results are valid.

A string, only results are returned, which _id equal the value of the string

An example object, defining a set of attributes.
Only results having these attributes are matched.

A list containing example objects and/or strings.
All results matching at least one of the elements in the list are returned.

Get vertices from edges.

Get vertex from of an edge

Get the source vertex of an edge

graph._fromVertex(edgeId)

Returns the vertex defined with the attribute _from of the edge with edgeId as its _id.

_neighbors

Get all neighbors of the vertices defined by the example

graph._neighbors(vertexExample, options)

The function accepts an id, an example, a list of examples or even an empty
example as parameter for vertexExample.
The complexity of this method is O(n*m^x) with n being the vertices defined by the
parameter vertexExamplex, m the average amount of neighbors and x the maximal depths.
Hence the default call would have a complexity of O(n*m);

_commonNeighbors

This function returns the intersection of graph_module._neighbors(vertex1Example, optionsVertex1)
and graph_module._neighbors(vertex2Example, optionsVertex2).
For parameter documentation see _neighbors.

The complexity of this method is O(n*m^x) with n being the maximal amount of vertices
defined by the parameters vertexExamples, m the average amount of neighbors and x the
maximal depths.
Hence the default call would have a complexity of O(n*m);

_shortestPath

The _shortestPath function returns all shortest paths of a graph.

graph._shortestPath(startVertexExample, endVertexExample, options)

This function determines all shortest paths in a graph.
The function accepts an id, an example, a list of examples
or even an empty example as parameter for
start and end vertex.
The length of a path is by default the amount of edges from one start vertex to
an end vertex. The option weight allows the user to define an edge attribute
representing the length.

direction: The direction of the edges as a string.
Possible values are outbound, inbound and any (default).

edgeCollectionRestriction: One or multiple edge
collection names. Only edges from these collections will be considered for the path.

startVertexCollectionRestriction: One or multiple vertex
collection names. Only vertices from these collections will be considered as
start vertex of a path.

endVertexCollectionRestriction: One or multiple vertex
collection names. Only vertices from these collections will be considered as
end vertex of a path.

weight: The name of the attribute of
the edges containing the length as a string.

defaultWeight: Only used with the option weight.
If an edge does not have the attribute named as defined in option weight this default
is used as length.
If no default is supplied the default would be positive Infinity so the path could
not be calculated.

Examples

A route planner example, shortest path from all german to all french cities:

options (optional) An object defining further options. Can have the following values:

direction: The direction of the edges. Possible values are outbound, inbound and any (default).

edgeCollectionRestriction : One or a list of edge-collection names that should be
considered to be on the path.

startVertexCollectionRestriction : One or a list of vertex-collection names that should be
considered for source vertices.

endVertexCollectionRestriction : One or a list of vertex-collection names that should be
considered for target vertices.

weight: The name of the attribute of the edges containing the weight.

defaultWeight: Only used with the option weight.
If an edge does not have the attribute named as defined in option weight this default
is used as weight.
If no default is supplied the default would be positive infinity so the path and
hence the eccentricity can not be calculated.

options (optional) An object defining further options. Can have the following values:

direction: The direction of the edges. Possible values are outbound, inbound and any (default).

edgeCollectionRestriction : One or a list of edge-collection names that should be
considered to be on the path.

startVertexCollectionRestriction : One or a list of vertex-collection names that should be
considered for source vertices.

endVertexCollectionRestriction : One or a list of vertex-collection names that should be
considered for target vertices.

weight: The name of the attribute of the edges containing the weight.

defaultWeight: Only used with the option weight.
If an edge does not have the attribute named as defined in option weight this default
is used as weight.
If no default is supplied the default would be positive infinity so the path and
hence the closeness can not be calculated.

_absoluteBetweenness

options (optional) An object defining further options. Can have the following values:

direction: The direction of the edges. Possible values are outbound, inbound and any (default).

weight: The name of the attribute of the edges containing the weight.

defaultWeight: Only used with the option weight.
If an edge does not have the attribute named as defined in option weight this default
is used as weight.
If no default is supplied the default would be positive infinity so the path and
hence the betweenness can not be calculated.

_radius

options (optional) An object defining further options. Can have the following values:

direction: The direction of the edges. Possible values are outbound, inbound and any (default).

weight: The name of the attribute of the edges containing the weight.

defaultWeight: Only used with the option weight.
If an edge does not have the attribute named as defined in option weight this default
is used as weight.
If no default is supplied the default would be positive infinity so the path and
hence the radius can not be calculated.

_diameter

options (optional) An object defining further options. Can have the following values:

direction: The direction of the edges. Possible values are outbound, inbound and any (default).

weight: The name of the attribute of the edges containing the weight.

defaultWeight: Only used with the option weight.
If an edge does not have the attribute named as defined in option weight this default
is used as weight.
If no default is supplied the default would be positive infinity so the path and
hence the radius can not be calculated.