Skip to content

Commit f9555d8

Browse files
authored
Merge pull request #60 from petercorke/feat/spatial-queries
feat: within, near, subgraph, coordinates and an optional k-d tree
2 parents d33a0dc + 3973f82 commit f9555d8

4 files changed

Lines changed: 1294 additions & 3 deletions

File tree

‎docs/source/analysis.rst‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,29 @@ Structure and connectivity
4949
Geometry and consistency
5050
^^^^^^^^^^^^^^^^^^^^^^^^^
5151

52+
For a graph whose vertices have coordinates,
53+
:meth:`~pgraph.PGraph.Graph.coordinates` is the matrix of them, one column per
54+
vertex. :meth:`~pgraph.PGraph.Graph.closest` finds the nearest vertex to a
55+
point, :meth:`~pgraph.PGraph.Graph.near` the vertices within a distance of a
56+
point and :meth:`~pgraph.PGraph.Graph.within` the vertices inside a box. Passing
57+
the result of the last to :meth:`~pgraph.PGraph.Graph.subgraph` gives the part of
58+
the graph in a region, without the edges that cross its border, and a boolean
59+
mask computed from the coordinates selects in the same way.
60+
61+
These are a single pass over the vertices. For a large graph that is queried
62+
often, :meth:`~pgraph.PGraph.Graph.build_kdtree` builds an index that
63+
:meth:`~pgraph.PGraph.Graph.closest` and :meth:`~pgraph.PGraph.Graph.near` then
64+
use, which needs scipy and is for the built-in metrics.
65+
5266
.. autosummary::
5367
:nosignatures:
5468

69+
~pgraph.PGraph.Graph.coordinates
5570
~pgraph.PGraph.Graph.closest
71+
~pgraph.PGraph.Graph.near
72+
~pgraph.PGraph.Graph.within
73+
~pgraph.PGraph.Graph.build_kdtree
74+
~pgraph.PGraph.Graph.subgraph
5675
~pgraph.PGraph.Graph.validate
5776

5877
The matrices of a graph (:meth:`~pgraph.PGraph.Graph.adjacency`,
@@ -153,7 +172,12 @@ Details
153172
.. automethod:: pgraph.PGraph.Graph.samecomponent
154173
.. automethod:: pgraph.PGraph.Graph.connectivity
155174
.. automethod:: pgraph.PGraph.Graph.average_degree
175+
.. automethod:: pgraph.PGraph.Graph.coordinates
156176
.. automethod:: pgraph.PGraph.Graph.closest
177+
.. automethod:: pgraph.PGraph.Graph.near
178+
.. automethod:: pgraph.PGraph.Graph.within
179+
.. automethod:: pgraph.PGraph.Graph.build_kdtree
180+
.. automethod:: pgraph.PGraph.Graph.subgraph
157181
.. automethod:: pgraph.PGraph.Graph.validate
158182

159183
.. autoproperty:: pgraph.PGraph.Vertex.name

0 commit comments

Comments
 (0)