Skip to content

Commit 02fecd6

Browse files
committed
Docs updates; fixes #265
1 parent ea4e830 commit 02fecd6

File tree

2 files changed

+165
-20
lines changed

2 files changed

+165
-20
lines changed

docs/source/types/graph.rst

Lines changed: 142 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ Graph Data Types
44

55
Cypher queries can return entire graph structures as well as individual property values.
66

7-
, The graph types model graph data returned from a Cypher query.
7+
The graph data types detailed here model graph data returned from a Cypher query.
88
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.
99
The identity or properties of that entity should be passed explicitly instead.
1010

11-
All graph values returned within a given :class:`.StatementResult` are contained within a :class:`.Graph` instance, accessible via :meth:`.StatementResult.graph`.
1211
The driver contains a corresponding class for each of the graph types that can be returned.
1312

1413
============= ======================
@@ -19,22 +18,149 @@ Relationship :class:`.Relationship`
1918
Path :class:`.Path`
2019
============= ======================
2120

22-
.. autoclass:: neo4j.types.graph.Graph
23-
:members:
21+
.. class:: neo4j.types.graph.Graph
2422

25-
.. autoclass:: neo4j.types.graph.Entity
26-
:members:
23+
A local, self-contained graph object that acts as a container for :class:`.Node` and :class:`.Relationship` instances.
24+
This is typically obtained via the :meth:`.BoltStatementResult.graph` method.
2725

28-
.. autoclass:: neo4j.types.graph.EntitySetView
29-
:members:
26+
.. autoattribute:: nodes
3027

31-
.. autoclass:: neo4j.types.graph.Node
32-
:members:
33-
:inherited-members:
28+
.. autoattribute:: relationships
3429

35-
.. autoclass:: neo4j.types.graph.Relationship
36-
:members:
37-
:inherited-members:
30+
.. automethod:: relationship_type
3831

39-
.. autoclass:: neo4j.types.graph.Path
40-
:members:
32+
33+
.. class:: neo4j.types.graph.Node
34+
35+
.. describe:: node == other
36+
37+
Compares nodes for equality.
38+
39+
.. describe:: node != other
40+
41+
Compares nodes for inequality.
42+
43+
.. describe:: hash(node)
44+
45+
Computes the hash of a node.
46+
47+
.. describe:: len(node)
48+
49+
Returns the number of properties on a node.
50+
51+
.. describe:: iter(node)
52+
53+
Iterates through all properties on a node.
54+
55+
.. describe:: node[key]
56+
57+
Returns a node property by key.
58+
Raises :exc:`KeyError` if the key does not exist.
59+
60+
.. describe:: key in node
61+
62+
Checks whether a property key exists for a given node.
63+
64+
.. autoattribute:: graph
65+
66+
.. autoattribute:: id
67+
68+
.. autoattribute:: labels
69+
70+
.. automethod:: get
71+
72+
.. automethod:: keys
73+
74+
.. automethod:: values
75+
76+
.. automethod:: items
77+
78+
79+
.. class:: neo4j.types.graph.Relationship
80+
81+
.. describe:: relationship == other
82+
83+
Compares relationships for equality.
84+
85+
.. describe:: relationship != other
86+
87+
Compares relationships for inequality.
88+
89+
.. describe:: hash(relationship)
90+
91+
Computes the hash of a relationship.
92+
93+
.. describe:: len(relationship)
94+
95+
Returns the number of properties on a relationship.
96+
97+
.. describe:: iter(relationship)
98+
99+
Iterates through all properties on a relationship.
100+
101+
.. describe:: relationship[key]
102+
103+
Returns a relationship property by key.
104+
Raises :exc:`KeyError` if the key does not exist.
105+
106+
.. describe:: key in relationship
107+
108+
Checks whether a property key exists for a given relationship.
109+
110+
.. describe:: type(relationship)
111+
112+
Returns the type (class) of a relationship.
113+
Relationship objects belong to a custom subtype based on the type name in the underlying database.
114+
115+
.. autoattribute:: graph
116+
117+
.. autoattribute:: id
118+
119+
.. autoattribute:: nodes
120+
121+
.. autoattribute:: start_node
122+
123+
.. autoattribute:: end_node
124+
125+
.. autoattribute:: type
126+
127+
.. automethod:: get
128+
129+
.. automethod:: keys
130+
131+
.. automethod:: values
132+
133+
.. automethod:: items
134+
135+
136+
.. class:: neo4j.types.graph.Path
137+
138+
.. describe:: path == other
139+
140+
Compares paths for equality.
141+
142+
.. describe:: path != other
143+
144+
Compares paths for inequality.
145+
146+
.. describe:: hash(path)
147+
148+
Computes the hash of a path.
149+
150+
.. describe:: len(path)
151+
152+
Returns the number of relationships in a path.
153+
154+
.. describe:: iter(path)
155+
156+
Iterates through all the relationships in a path.
157+
158+
.. autoattribute:: graph
159+
160+
.. autoattribute:: nodes
161+
162+
.. autoattribute:: start_node
163+
164+
.. autoattribute:: end_node
165+
166+
.. autoattribute:: relationships

neo4j/types/graph.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,13 @@ def __init__(self):
4949

5050
@property
5151
def nodes(self):
52-
""" Access an :class:`.EntitySetView` of the nodes in this
53-
graph.
52+
""" Access a set view of the nodes in this graph.
5453
"""
5554
return self._node_set_view
5655

5756
@property
5857
def relationships(self):
59-
""" Access an :class:`.EntitySetView` of the relationships in
60-
this graph.
58+
""" Access a set view of the relationships in this graph.
6159
"""
6260
return self._relationship_set_view
6361

@@ -201,6 +199,8 @@ def __repr__(self):
201199

202200
@property
203201
def labels(self):
202+
""" The set of labels attached to this node.
203+
"""
204204
return frozenset(self._labels)
205205

206206

@@ -224,18 +224,27 @@ def __repr__(self):
224224

225225
@property
226226
def nodes(self):
227+
""" The pair of nodes which this relationship connects.
228+
"""
227229
return self._start_node, self._end_node
228230

229231
@property
230232
def start_node(self):
233+
""" The start node of this relationship.
234+
"""
231235
return self._start_node
232236

233237
@property
234238
def end_node(self):
239+
""" The end node of this relationship.
240+
"""
235241
return self._end_node
236242

237243
@property
238244
def type(self):
245+
""" The type name of this relationship.
246+
This is functionally equivalent to ``type(relationship).__name__``.
247+
"""
239248
return type(self).__name__
240249

241250
@property
@@ -294,22 +303,32 @@ def __iter__(self):
294303

295304
@property
296305
def graph(self):
306+
""" The :class:`.Graph` to which this path belongs.
307+
"""
297308
return self._nodes[0].graph
298309

299310
@property
300311
def nodes(self):
312+
""" The sequence of :class:`.Node` objects in this path.
313+
"""
301314
return self._nodes
302315

303316
@property
304317
def start_node(self):
318+
""" The first :class:`.Node` in this path.
319+
"""
305320
return self._nodes[0]
306321

307322
@property
308323
def end_node(self):
324+
""" The last :class:`.Node` in this path.
325+
"""
309326
return self._nodes[-1]
310327

311328
@property
312329
def relationships(self):
330+
""" The sequence of :class:`.Relationship` objects in this path.
331+
"""
313332
return self._relationships
314333

315334
@property

0 commit comments

Comments
 (0)