Graph Data Types¶
Cypher queries can return entire graph structures as well as individual property values.
The graph data types detailed here model graph data returned from a Cypher query. Graph values cannot be passed in as parameters as it would be unclear whether the entity was intended to be passed by reference or by value. The identity or properties of that entity should be passed explicitly instead.
The driver contains a corresponding class for each of the graph types that can be returned.
Cypher Type |
Python Type |
---|---|
Node |
|
Relationship |
|
Path |
-
class
neo4j.types.graph.
Graph
¶ A local, self-contained graph object that acts as a container for
Node
andRelationship
instances. This is typically obtained via theBoltStatementResult.graph()
method.-
Graph.
nodes
¶ Access a set view of the nodes in this graph.
-
Graph.
relationships
¶ Access a set view of the relationships in this graph.
-
Graph.
relationship_type
(name)¶ Obtain a
Relationship
subclass for a given relationship type name.
-
-
class
neo4j.types.graph.
Node
¶ -
node == other
Compares nodes for equality.
-
node != other
Compares nodes for inequality.
-
hash(node)
Computes the hash of a node.
-
len(node)
Returns the number of properties on a node.
-
iter(node)
Iterates through all properties on a node.
-
node[key]
Returns a node property by key. Raises
KeyError
if the key does not exist.
-
key in node
Checks whether a property key exists for a given node.
-
Node.
labels
¶ The set of labels attached to this node.
-
Node.
get
(name, default=None)¶ Get a property value by name, optionally with a default.
-
Node.
keys
()¶ Return an iterable of all property names.
-
Node.
values
()¶ Return an iterable of all property values.
-
Node.
items
()¶ Return an iterable of all property name-value pairs.
-
-
class
neo4j.types.graph.
Relationship
¶ -
relationship == other
Compares relationships for equality.
-
relationship != other
Compares relationships for inequality.
-
hash(relationship)
Computes the hash of a relationship.
-
len(relationship)
Returns the number of properties on a relationship.
-
iter(relationship)
Iterates through all properties on a relationship.
-
relationship[key]
Returns a relationship property by key. Raises
KeyError
if the key does not exist.
-
key in relationship
Checks whether a property key exists for a given relationship.
-
type(relationship)
Returns the type (class) of a relationship. Relationship objects belong to a custom subtype based on the type name in the underlying database.
-
Relationship.
nodes
¶ The pair of nodes which this relationship connects.
-
Relationship.
start_node
¶ The start node of this relationship.
-
Relationship.
end_node
¶ The end node of this relationship.
-
Relationship.
type
¶ The type name of this relationship. This is functionally equivalent to
type(relationship).__name__
.
-
Relationship.
get
(name, default=None)¶ Get a property value by name, optionally with a default.
-
Relationship.
keys
()¶ Return an iterable of all property names.
-
Relationship.
values
()¶ Return an iterable of all property values.
-
Relationship.
items
()¶ Return an iterable of all property name-value pairs.
-
-
class
neo4j.types.graph.
Path
¶ -
path == other
Compares paths for equality.
-
path != other
Compares paths for inequality.
-
hash(path)
Computes the hash of a path.
-
len(path)
Returns the number of relationships in a path.
-
iter(path)
Iterates through all the relationships in a path.
-
Path.
relationships
¶ The sequence of
Relationship
objects in this path.
-