|
3 | 3 | <div align="center"> |
4 | 4 | <img src="https://raw.githubusercontent.com/petercorke/pgraph-python/main/docs/figs/pgraph_logo.png" width="450" alt="pgraph logo"> |
5 | 5 | <br> |
6 | | - <strong>Mathematical graphs for Python</strong> |
| 6 | + <strong>Graphs for Python</strong> |
7 | 7 | <br><br> |
8 | 8 |
|
9 | 9 | [](https://pypi.org/project/pgraph-python/) |
|
35 | 35 | [](https://matplotlib.org) |
36 | 36 | [](https://github.com/petercorke/spatialmath-python) |
37 | 37 |
|
38 | | -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. |
| 38 | +This package provides classes for directed and undirected graphs: vertices |
| 39 | +connected by edges, with edge costs and path planning. Self-loops and |
| 40 | +parallel edges are permitted. |
| 41 | + |
| 42 | +Vertices can optionally be *embedded*: given a coordinate in a space of any |
| 43 | +dimension. Edge costs are then computed from the vertex positions using a |
| 44 | +distance metric (Euclidean, Manhattan, SE(2), or your own), the vertex nearest |
| 45 | +a point can be found, `A*` uses the metric as its heuristic, and the graph can |
| 46 | +be plotted, or exported with its layout preserved. |
39 | 47 |
|
40 | 48 |  |
41 | 49 |
|
@@ -89,18 +97,18 @@ Graphs belong to the class `UGraph` or `DGraph` for undirected or directed graph |
89 | 97 | - `g.incidence()` incidence matrix |
90 | 98 |
|
91 | 99 | ### Properties and methods of a vertex |
92 | | -Vertices belong to the class `UVertex` (for undirected graphs) or `DVertex` (for directed graphs), which are each subclasses of `Vertex`. |
| 100 | +Vertices belong to the class `UVertex` (for undirected graphs) or `DVertex` (for directed graphs), which are each subclasses of `BaseVertex`. |
93 | 101 |
|
94 | 102 | - `v.coord` the coordinate vector for embedded graph (optional) |
95 | 103 | - `v.name` the name of the vertex (optional) |
96 | | -- `v.neighbours()` is a list of the neighbouring vertices |
| 104 | +- `v.adjacent()` is a list of the adjacent vertices (`neighbours()` and `neighbors()` are the same) |
97 | 105 | - `v1.samecomponent(v2)` predicate for vertices belonging to the same component |
98 | 106 |
|
99 | 107 | Vertices can be named and referenced by name. |
100 | 108 |
|
101 | 109 | ### Properties and methods of an edge |
102 | 110 | Edges are instances of the class `Edge`. |
103 | | -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. |
| 111 | +Each edge references a pair of vertices, the graph lists all of its edges in `g.edges()`, 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. |
104 | 112 |
|
105 | 113 | - `e.cost` cost of edge for planning methods |
106 | 114 | - `e.next(v)` vertex on edge `e` that is not `v` |
@@ -135,12 +143,6 @@ for f in f1.neighbours(): |
135 | 143 | # say hi to the neighbours |
136 | 144 | ``` |
137 | 145 |
|
138 | | -## Under the hood |
139 | | - |
140 | | -The key objects and their interactions are shown below. |
141 | | - |
142 | | - |
143 | | - |
144 | 146 | ## MATLAB version |
145 | 147 |
|
146 | 148 | This is a re-engineered version of [PGraph.m](https://github.com/petercorke/spatialmath-matlab/blob/main/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. |
|
0 commit comments