pgraph-python 0.6.1__tar.gz → 0.6.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Peter Corke
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.1
2
+ Name: pgraph-python
3
+ Version: 0.6.3
4
+ Summary: Mathematical graphs for Python
5
+ Author-email: Peter Corke <rvc@petercorke.com>
6
+ Project-URL: Homepage, https://github.com/petercorke/pgraph-python
7
+ Project-URL: Bug Tracker, https://github.com/pypa/sampleproject/issues
8
+ Project-URL: Documentation, https://petercorke.github.io/pgraph-python
9
+ Project-URL: GitHub Source, https://github.com/petercorke/pgraph-python
10
+ Project-URL: Changelog, https://github.com/petercorke/pgraph-python/blob/master/CHANGELOG.md
11
+ Project-URL: Coverage, https://codecov.io/gh/petercorke/spatialmath-python
12
+ Keywords: python,graph,directed graph,undirected graph,a* search,adjacency matrix,Laplacian matrix,plotting,optimal path
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: License :: OSI Approved :: MIT License
21
+ Classifier: Operating System :: OS Independent
22
+ Requires-Python: >=3.7
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: spatialmath-python
26
+ Requires-Dist: numpy>=1.18.0
27
+ Requires-Dist: scipy
28
+ Requires-Dist: matplotlib
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest; extra == "dev"
31
+ Requires-Dist: pytest-cov; extra == "dev"
32
+ Provides-Extra: docs
33
+ Requires-Dist: sphinx; extra == "docs"
34
+ Requires-Dist: recommonmark; extra == "docs"
35
+ Requires-Dist: sphinx-rtd-theme; extra == "docs"
36
+ Requires-Dist: sphinx-autorun; extra == "docs"
37
+ Requires-Dist: sphinx-favicon; extra == "docs"
38
+
39
+ # PGraph: graphs for Python
40
+
41
+ [![A Python Robotics Package](https://raw.githubusercontent.com/petercorke/robotics-toolbox-python/master/.github/svg/py_collection.min.svg)](https://github.com/petercorke/robotics-toolbox-python)
42
+ [![Powered by Spatial Maths](https://raw.githubusercontent.com/petercorke/spatialmath-python/master/.github/svg/sm_powered.min.svg)](https://github.com/petercorke/spatialmath-python)
43
+ [![QUT Centre for Robotics Open Source](https://github.com/qcr/qcr.github.io/raw/master/misc/badge.svg)](https://qcr.github.io)
44
+
45
+ [![PyPI version fury.io](https://badge.fury.io/py/pgraph-python.svg)](https://pypi.python.org/pypi/pgraph-python/)
46
+ [![PyPI pyversions](https://img.shields.io/pypi/pyversions/pgraph-python)](https://pypi.python.org/pypi/pgraph-python/)
47
+ [![GitHub license](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/petercorke/pgraph-python/blob/master/LICENSE)
48
+
49
+ [![Build Status](https://github.com/petercorke/pgraph-python/actions/workflows/master.yml/badge.svg)](https://github.com/petercorke/pgraph-python/actions?query=workflow%3Abuild)
50
+ [![Coverage](https://codecov.io/gh/petercorke/pgraph-python/branch/master/graph/badge.svg)](https://codecov.io/gh/petercorke/pgraph-python)
51
+ ![pypi downloads](https://img.shields.io/pypi/dw/pgraph-python)
52
+
53
+ - [GitHub repository](https://github.com/petercorke/pgraph-python)
54
+ - [Wiki (examples and details)](https://github.com/petercorke/pgraph-python/wiki)
55
+ - [Documentation](https://petercorke.github.io/pgraph-python)
56
+ - [Changelog](https://github.com/petercorke/pgraph-python/blob/master/CHANGELOG.md)
57
+ - Dependencies: [`numpy`](https://numpy.org) [`spatialmath`](https://github.com/bdaiinstitute/spatialmath-python)
58
+
59
+
60
+ This Python package allows the manipulation of directed and non-directed graphs. Also supports embedded graphs. It is suitable for graphs with thousands of nodes.
61
+
62
+ ![road network](https://github.com/petercorke/pgraph-python/raw/master/examples/roads.png)
63
+
64
+ ```
65
+ from pgraph import *
66
+ import json
67
+
68
+ # load places and routes
69
+ with open('places.json', 'r') as f:
70
+ places = json.loads(f.read())
71
+ with open('routes.json', 'r') as f:
72
+ routes = json.loads(f.read())
73
+
74
+ # build the graph
75
+ g = UGraph()
76
+
77
+ for name, info in places.items():
78
+ g.add_vertex(name=name, coord=info["utm"])
79
+
80
+ for route in routes:
81
+ g.add_edge(route[0], route[1], cost=route[2])
82
+
83
+ # plan a path from Hughenden to Brisbane
84
+ p = g.path_Astar('Hughenden', 'Brisbane')
85
+ g.plot(block=False) # plot it
86
+ g.highlight_path(p) # overlay the path
87
+ ```
88
+
89
+ ### Properties and methods of the graph
90
+ Graphs belong to the class `UGraph` or `DGraph` for undirected or directed graphs respectively. The graph is essentially a container for the vertices.
91
+
92
+ - `g.add_vertex()` add a vertex
93
+ - `g.n` the number of vertices
94
+ - `g` is an iterator over vertices, can be used as `for vertex in g:`
95
+ - `g[i]` reference a vertex by its index or name
96
+
97
+ ***
98
+ - `g.add_edge()` connect two vertices
99
+ - `g.edges()` all edges in the graph
100
+ - `g.plot()` plots the vertices and edges
101
+ - `g.nc` the number of graph components, 1 if fully connected
102
+ - `g.component(v)` the component that vertex `v` belongs to
103
+
104
+ ***
105
+ - `g.path_BFS()` breadth-first search
106
+ - `g.path_Astar()` A* search
107
+
108
+ ***
109
+ - `g.adjacency()` adjacency matrix
110
+ - `g.Laplacian()` Laplacian matrix
111
+ - `g.incidence()` incidence matrix
112
+
113
+ ### Properties and methods of a vertex
114
+ Vertices belong to the class `UVertex` (for undirected graphs) or `DVertex` (for directed graphs), which are each subclasses of `Vertex`.
115
+
116
+ - `v.coord` the coordinate vector for embedded graph (optional)
117
+ - `v.name` the name of the vertex (optional)
118
+ - `v.neighbours()` is a list of the neighbouring vertices
119
+ - `v1.samecomponent(v2)` predicate for vertices belonging to the same component
120
+
121
+ Vertices can be named and referenced by name.
122
+
123
+ ### Properties and methods of an edge
124
+ Edges are instances of the class `Edge`.
125
+ Edges are not referenced by the graph object, each edge references a pair of vertices, and the vertices reference the edges. For a directed graph only the start vertex of an edge references the edge object, whereas for an undirected graph both vertices reference the edge object.
126
+
127
+ - `e.cost` cost of edge for planning methods
128
+ - `e.next(v)` vertex on edge `e` that is not `v`
129
+ - `e.v1`, `e.v2` the two vertices that define the edge `e`
130
+
131
+ ## Modifying a graph
132
+
133
+ - `g.remove(v)` remove vertex `v`
134
+ - `e.remove()` remove edge `e`
135
+
136
+ ## Subclasing pgraph classes
137
+
138
+ Consider a user class `Foo` that we would like to connect using a graph _overlay_, ie.
139
+ instances of `Foo` becomes vertices in a graph.
140
+
141
+ - Have it subclass either `DVertex` or `UVertex` depending on graph type
142
+ - Then place instances of `Foo` into the graph using `add_vertex` and create edges as required
143
+
144
+ ```
145
+ class Foo(UVertex):
146
+ # foo stuff goes here
147
+
148
+ f1 = Foo(...)
149
+ f2 = Foo(...)
150
+
151
+ g = UGraph() # create a new undirected graph
152
+ g.add_vertex(f1)
153
+ g.add_vertex(f2)
154
+
155
+ f1.connect(f2, cost=3)
156
+ for f in f1.neighbours():
157
+ # say hi to the neighbours
158
+ ```
159
+
160
+ ## Under the hood
161
+
162
+ The key objects and their interactions are shown below.
163
+
164
+ ![data structures](https://github.com/petercorke/pgraph-python/raw/master/docs/source/datastructures.png)
165
+
166
+ ## MATLAB version
167
+
168
+ This is a re-engineered version of [PGraph.m](https://github.com/petercorke/spatialmath-matlab/blob/master/PGraph.m) which ships as part of the [Spatial Math Toolbox for MATLAB](https://github.com/petercorke/spatialmath-matlab). This class is used to support bundle adjustment, pose-graph SLAM and various planners such as PRM, RRT and Lattice.
169
+
170
+ The Python version was designed from the start to work with directed and undirected graphs, whereas directed graphs were a late addition to the MATLAB version. Semantics are similar but not identical. In particular the use of subclassing rather than references to
171
+ _user data_ is encouraged.
172
+
173
+
174
+
175
+
176
+
@@ -1,16 +1,22 @@
1
- # PGraph: simple graphs for Python
1
+ # PGraph: graphs for Python
2
+
3
+ [![A Python Robotics Package](https://raw.githubusercontent.com/petercorke/robotics-toolbox-python/master/.github/svg/py_collection.min.svg)](https://github.com/petercorke/robotics-toolbox-python)
4
+ [![Powered by Spatial Maths](https://raw.githubusercontent.com/petercorke/spatialmath-python/master/.github/svg/sm_powered.min.svg)](https://github.com/petercorke/spatialmath-python)
5
+ [![QUT Centre for Robotics Open Source](https://github.com/qcr/qcr.github.io/raw/master/misc/badge.svg)](https://qcr.github.io)
2
6
 
3
- ![pypi downloads](https://img.shields.io/pypi/dw/pgraph-python)
4
7
  [![PyPI version fury.io](https://badge.fury.io/py/pgraph-python.svg)](https://pypi.python.org/pypi/pgraph-python/)
5
- [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/petercorke/pgraph-python.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/petercorke/pgraph-python/context:python)
6
8
  [![PyPI pyversions](https://img.shields.io/pypi/pyversions/pgraph-python)](https://pypi.python.org/pypi/pgraph-python/)
7
- [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/petercorke/pgraph-python/graphs/commit-activity)
8
9
  [![GitHub license](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/petercorke/pgraph-python/blob/master/LICENSE)
9
- [![QUT Centre for Robotics Open Source](https://github.com/qcr/qcr.github.io/raw/master/misc/badge.svg)](https://qcr.github.io)
10
10
 
11
- - GitHub repository: [https://github.com/petercorke/pgraph-python](https://github.com/petercorke/pgraph-python)
12
- - Documentation: [https://petercorke.github.io/pgraph-python](https://petercorke.github.io/pgraph-python)
13
- - Dependencies: `numpy`
11
+ [![Build Status](https://github.com/petercorke/pgraph-python/actions/workflows/master.yml/badge.svg)](https://github.com/petercorke/pgraph-python/actions?query=workflow%3Abuild)
12
+ [![Coverage](https://codecov.io/gh/petercorke/pgraph-python/branch/master/graph/badge.svg)](https://codecov.io/gh/petercorke/pgraph-python)
13
+ ![pypi downloads](https://img.shields.io/pypi/dw/pgraph-python)
14
+
15
+ - [GitHub repository](https://github.com/petercorke/pgraph-python)
16
+ - [Wiki (examples and details)](https://github.com/petercorke/pgraph-python/wiki)
17
+ - [Documentation](https://petercorke.github.io/pgraph-python)
18
+ - [Changelog](https://github.com/petercorke/pgraph-python/blob/master/CHANGELOG.md)
19
+ - Dependencies: [`numpy`](https://numpy.org) [`spatialmath`](https://github.com/bdaiinstitute/spatialmath-python)
14
20
 
15
21
 
16
22
  This Python package allows the manipulation of directed and non-directed graphs. Also supports embedded graphs. It is suitable for graphs with thousands of nodes.