scgraph 2.8.0__tar.gz → 2.8.2__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.
Files changed (24) hide show
  1. {scgraph-2.8.0/scgraph.egg-info → scgraph-2.8.2}/PKG-INFO +65 -33
  2. {scgraph-2.8.0 → scgraph-2.8.2}/README.md +64 -32
  3. {scgraph-2.8.0 → scgraph-2.8.2}/pyproject.toml +1 -1
  4. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/__init__.py +64 -32
  5. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/grid.py +12 -4
  6. {scgraph-2.8.0 → scgraph-2.8.2/scgraph.egg-info}/PKG-INFO +65 -33
  7. {scgraph-2.8.0 → scgraph-2.8.2}/setup.cfg +1 -1
  8. {scgraph-2.8.0 → scgraph-2.8.2}/LICENSE +0 -0
  9. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/cache.py +0 -0
  10. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/core.py +0 -0
  11. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/geograph.py +0 -0
  12. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/geographs/__init__.py +0 -0
  13. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/geographs/marnet.py +0 -0
  14. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/geographs/north_america_rail.py +0 -0
  15. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/geographs/oak_ridge_maritime.py +0 -0
  16. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/geographs/us_freeway.py +0 -0
  17. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/graph.py +0 -0
  18. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/helpers/__init__.py +0 -0
  19. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/helpers/shape_mover_utils.py +0 -0
  20. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/spanning.py +0 -0
  21. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph/utils.py +0 -0
  22. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph.egg-info/SOURCES.txt +0 -0
  23. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph.egg-info/dependency_links.txt +0 -0
  24. {scgraph-2.8.0 → scgraph-2.8.2}/scgraph.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scgraph
3
- Version: 2.8.0
3
+ Version: 2.8.2
4
4
  Summary: Determine an approximate route between two points on earth.
5
5
  Author-email: Connor Makowski <conmak@mit.edu>
6
6
  Project-URL: Homepage, https://github.com/connor-makowski/scgraph
@@ -33,34 +33,62 @@ Low Level: https://connor-makowski.github.io/scgraph/scgraph/core.html
33
33
 
34
34
  ## Key Features
35
35
 
36
- - Calculate the shortest path between two points on earth using a latitude / longitude pair
37
- - Inputs:
38
- - A latitude / longitude pair for the origin
39
- - A latitude / longitude pair for the destination
40
- - Calculation:
41
- - Algorithms:
42
- - Dijkstra's algorithm (Modified for sparse networks)
43
- - Modified to support sparse network data structures
44
- - Modified Sparse Dijkstra algorithm
45
- - Modified for O((n+m)log(n)) performance where n is the number of nodes and m is the number of edges
46
- - Uses a priority queue to improve performance on large graphs
47
- - A* algorithm (Extension of the Modified Sparse Dijkstra)
48
- - Uses a heuristic function to improve performance on large graphs
49
- - Note: The heuristic function is optional and defaults to Dijkstra's algorithm
50
- - Possible future support for other algorithms
51
- - Distances:
52
- - Uses the [haversine formula](https://en.wikipedia.org/wiki/Haversine_formula) to calculate the distance between two points on earth
53
- - Returns:
54
- - `path`:
55
- - A list of dictionaries (`latitude` and `longitude`) that make up the shortest path
56
- - `length`:
57
- - The distance in kilometers between the two points
58
- - Antimeridian support
59
- - Arbitrary start and end points
60
- - Arbitrary network data sets
61
- - Grid based graphs
62
- - Cached shortest path calculations for very fast repetative calculations to or from the same point in a graph.
63
- - Note: Geographs are not yet supported for this feature
36
+ - `GeoGraph`s:
37
+ - A geographic graph data structure that allows for the calculation of shortest paths between two points on earth
38
+ - Uses latitude / longitude pairs to represent points on earth
39
+ - Supports maritime, rail, road and other geographic networks
40
+ - Uses a sparse network data structure to represent the graph
41
+ - How to use it - Calculate the shortest path between two points on earth
42
+ - Inputs:
43
+ - A latitude / longitude pair for the origin
44
+ - A latitude / longitude pair for the destination
45
+ - Calculation:
46
+ - Algorithms:
47
+ - Dijkstra's algorithm
48
+ - Modified to support sparse network data structures
49
+ - Modified Dijkstra algorithm
50
+ - Modified for O((n+m)log(n)) performance where n is the number of nodes and m is the number of edges
51
+ - Uses a priority queue and other improvements to run fast on large graphs
52
+ - A* algorithm (Extension of the Modified Dijkstra)
53
+ - Uses a heuristic function to improve performance on large graphs
54
+ - Possible future support for other algorithms
55
+ - Returns:
56
+ - `path`:
57
+ - A list of lists `[latitude, longitude]` that make up the shortest path
58
+ - `length`:
59
+ - The distance (in the units requested) between the two points
60
+ - Precompiled Geographs offer Antimeridian support
61
+ - Arbitrary start and end points are supported
62
+ - Start and end points do not need to be in the graph
63
+ - `GridGraph`s:
64
+ - A grid based graph data structure that allows for the calculation of shortest paths between two points on a grid
65
+ - Supports arbitrary grid sizes and blockages
66
+ - Uses a sparse network data structure to represent the graph
67
+ - How to use it - Calculate the shortest path between two points on a grid
68
+ - Inputs:
69
+ - A (x,y) coordinate on the grid for the origin
70
+ - A (x,y) coordinate on the grid for the destination
71
+ - Calculation:
72
+ - Algorithms:
73
+ - Dijkstra's algorithm
74
+ - Modified Dijkstra algorithm
75
+ - A* algorithm (Extension of the Modified Dijkstra)
76
+ - Returns:
77
+ - `length`:
78
+ - The distance between the two points on the grid
79
+ - `coordinate_path`:
80
+ - A list of dicts `{"x": x, "y": y}` representing the path taken through the grid
81
+ - Arbitrary start and end points are supported
82
+ - Start and end points do not need to be in the graph
83
+ - Arbitrary connection matricies are supported
84
+ - Cardinal connections (up, down, left, right) and diagonal connections (up-left, up-right, down-left, down-right) are used by default
85
+ - Custom connection matricies can be used to change the connections between grid items
86
+ - Cached shortest path calculations can be used for very fast repetative calculations to or from the same point in a GridGraph.
87
+ - Other Useful Features:
88
+ - Graph
89
+ - A low level graph object that has methods for validating graphs, calculating shortest paths, and more
90
+ - CacheGraphs
91
+ - A graph extension that caches spanning trees for fast shortest path calculations on repeat calls from the same origin node
64
92
 
65
93
 
66
94
  ## Setup
@@ -84,7 +112,7 @@ pip install scgraph
84
112
 
85
113
  # Getting Started
86
114
 
87
- ## Basic Usage
115
+ ## Basic Geograph Usage
88
116
 
89
117
  Get the shortest path between two points on earth using a latitude / longitude pair
90
118
  In this case, calculate the shortest maritime path between Shanghai, China and Savannah, Georgia, USA.
@@ -103,7 +131,7 @@ output = marnet_geograph.get_shortest_path(
103
131
  print('Length: ',output['length']) #=> Length: 19596.4653
104
132
  ```
105
133
 
106
- In the above example, the `output` variable is a dictionary with three keys: `length` and `coordinate_path`.
134
+ In the above example, the `output` variable is a dictionary with two keys: `length` and `coordinate_path`.
107
135
 
108
136
  - `length`: The distance between the passed origin and destination when traversing the graph along the shortest path
109
137
  - Notes:
@@ -153,10 +181,10 @@ For more examples including viewing the output on a map, see the [example notebo
153
181
  ## GridGraph usage
154
182
 
155
183
  Example:
156
- - Create a grid of 20x100 cells.
184
+ - Create a grid of 20x20 cells.
157
185
  - This creates a grid based graph with connections to all 8 neighbors for each grid item.
158
186
  - Each grid item has 4 cardinal connections at length 1 and 4 diagonal connections at length sqrt(2)
159
- - Create a wall from (10,5) to (10,99).
187
+ - Create a wall from (10,5) to (10,19).
160
188
  - This would foce any path to go to the bottom of the graph to get around the wall.
161
189
  - Get the shortest path between (2,10) and (18,10)
162
190
  - Note: The length of this path should be 16 without the wall and 20.9704 with the wall.
@@ -195,6 +223,8 @@ print(output)
195
223
 
196
224
  ## Advanced Usage
197
225
 
226
+ ### Using scgraph_data geographs
227
+
198
228
  Using `scgraph_data` geographs:
199
229
  - Note: Make sure to install the `scgraph_data` package before using these geographs
200
230
  ```py
@@ -212,6 +242,7 @@ output = world_railways_geograph.get_shortest_path(
212
242
  )
213
243
  ```
214
244
 
245
+ ### Using Geographs for Visualization
215
246
  Get a geojson line path of an output for easy visualization:
216
247
  - Note: `mapshaper.org` and `geojson.io` are good tools for visualizing geojson files
217
248
  ```py
@@ -227,6 +258,7 @@ output = marnet_geograph.get_shortest_path(
227
258
  get_line_path(output, filename='output.geojson')
228
259
  ```
229
260
 
261
+ ### Custom Graphs and Geographs
230
262
  Modify an existing geograph: See the notebook [here](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/geograph_modifications.ipynb)
231
263
 
232
264
 
@@ -17,34 +17,62 @@ Low Level: https://connor-makowski.github.io/scgraph/scgraph/core.html
17
17
 
18
18
  ## Key Features
19
19
 
20
- - Calculate the shortest path between two points on earth using a latitude / longitude pair
21
- - Inputs:
22
- - A latitude / longitude pair for the origin
23
- - A latitude / longitude pair for the destination
24
- - Calculation:
25
- - Algorithms:
26
- - Dijkstra's algorithm (Modified for sparse networks)
27
- - Modified to support sparse network data structures
28
- - Modified Sparse Dijkstra algorithm
29
- - Modified for O((n+m)log(n)) performance where n is the number of nodes and m is the number of edges
30
- - Uses a priority queue to improve performance on large graphs
31
- - A* algorithm (Extension of the Modified Sparse Dijkstra)
32
- - Uses a heuristic function to improve performance on large graphs
33
- - Note: The heuristic function is optional and defaults to Dijkstra's algorithm
34
- - Possible future support for other algorithms
35
- - Distances:
36
- - Uses the [haversine formula](https://en.wikipedia.org/wiki/Haversine_formula) to calculate the distance between two points on earth
37
- - Returns:
38
- - `path`:
39
- - A list of dictionaries (`latitude` and `longitude`) that make up the shortest path
40
- - `length`:
41
- - The distance in kilometers between the two points
42
- - Antimeridian support
43
- - Arbitrary start and end points
44
- - Arbitrary network data sets
45
- - Grid based graphs
46
- - Cached shortest path calculations for very fast repetative calculations to or from the same point in a graph.
47
- - Note: Geographs are not yet supported for this feature
20
+ - `GeoGraph`s:
21
+ - A geographic graph data structure that allows for the calculation of shortest paths between two points on earth
22
+ - Uses latitude / longitude pairs to represent points on earth
23
+ - Supports maritime, rail, road and other geographic networks
24
+ - Uses a sparse network data structure to represent the graph
25
+ - How to use it - Calculate the shortest path between two points on earth
26
+ - Inputs:
27
+ - A latitude / longitude pair for the origin
28
+ - A latitude / longitude pair for the destination
29
+ - Calculation:
30
+ - Algorithms:
31
+ - Dijkstra's algorithm
32
+ - Modified to support sparse network data structures
33
+ - Modified Dijkstra algorithm
34
+ - Modified for O((n+m)log(n)) performance where n is the number of nodes and m is the number of edges
35
+ - Uses a priority queue and other improvements to run fast on large graphs
36
+ - A* algorithm (Extension of the Modified Dijkstra)
37
+ - Uses a heuristic function to improve performance on large graphs
38
+ - Possible future support for other algorithms
39
+ - Returns:
40
+ - `path`:
41
+ - A list of lists `[latitude, longitude]` that make up the shortest path
42
+ - `length`:
43
+ - The distance (in the units requested) between the two points
44
+ - Precompiled Geographs offer Antimeridian support
45
+ - Arbitrary start and end points are supported
46
+ - Start and end points do not need to be in the graph
47
+ - `GridGraph`s:
48
+ - A grid based graph data structure that allows for the calculation of shortest paths between two points on a grid
49
+ - Supports arbitrary grid sizes and blockages
50
+ - Uses a sparse network data structure to represent the graph
51
+ - How to use it - Calculate the shortest path between two points on a grid
52
+ - Inputs:
53
+ - A (x,y) coordinate on the grid for the origin
54
+ - A (x,y) coordinate on the grid for the destination
55
+ - Calculation:
56
+ - Algorithms:
57
+ - Dijkstra's algorithm
58
+ - Modified Dijkstra algorithm
59
+ - A* algorithm (Extension of the Modified Dijkstra)
60
+ - Returns:
61
+ - `length`:
62
+ - The distance between the two points on the grid
63
+ - `coordinate_path`:
64
+ - A list of dicts `{"x": x, "y": y}` representing the path taken through the grid
65
+ - Arbitrary start and end points are supported
66
+ - Start and end points do not need to be in the graph
67
+ - Arbitrary connection matricies are supported
68
+ - Cardinal connections (up, down, left, right) and diagonal connections (up-left, up-right, down-left, down-right) are used by default
69
+ - Custom connection matricies can be used to change the connections between grid items
70
+ - Cached shortest path calculations can be used for very fast repetative calculations to or from the same point in a GridGraph.
71
+ - Other Useful Features:
72
+ - Graph
73
+ - A low level graph object that has methods for validating graphs, calculating shortest paths, and more
74
+ - CacheGraphs
75
+ - A graph extension that caches spanning trees for fast shortest path calculations on repeat calls from the same origin node
48
76
 
49
77
 
50
78
  ## Setup
@@ -68,7 +96,7 @@ pip install scgraph
68
96
 
69
97
  # Getting Started
70
98
 
71
- ## Basic Usage
99
+ ## Basic Geograph Usage
72
100
 
73
101
  Get the shortest path between two points on earth using a latitude / longitude pair
74
102
  In this case, calculate the shortest maritime path between Shanghai, China and Savannah, Georgia, USA.
@@ -87,7 +115,7 @@ output = marnet_geograph.get_shortest_path(
87
115
  print('Length: ',output['length']) #=> Length: 19596.4653
88
116
  ```
89
117
 
90
- In the above example, the `output` variable is a dictionary with three keys: `length` and `coordinate_path`.
118
+ In the above example, the `output` variable is a dictionary with two keys: `length` and `coordinate_path`.
91
119
 
92
120
  - `length`: The distance between the passed origin and destination when traversing the graph along the shortest path
93
121
  - Notes:
@@ -137,10 +165,10 @@ For more examples including viewing the output on a map, see the [example notebo
137
165
  ## GridGraph usage
138
166
 
139
167
  Example:
140
- - Create a grid of 20x100 cells.
168
+ - Create a grid of 20x20 cells.
141
169
  - This creates a grid based graph with connections to all 8 neighbors for each grid item.
142
170
  - Each grid item has 4 cardinal connections at length 1 and 4 diagonal connections at length sqrt(2)
143
- - Create a wall from (10,5) to (10,99).
171
+ - Create a wall from (10,5) to (10,19).
144
172
  - This would foce any path to go to the bottom of the graph to get around the wall.
145
173
  - Get the shortest path between (2,10) and (18,10)
146
174
  - Note: The length of this path should be 16 without the wall and 20.9704 with the wall.
@@ -179,6 +207,8 @@ print(output)
179
207
 
180
208
  ## Advanced Usage
181
209
 
210
+ ### Using scgraph_data geographs
211
+
182
212
  Using `scgraph_data` geographs:
183
213
  - Note: Make sure to install the `scgraph_data` package before using these geographs
184
214
  ```py
@@ -196,6 +226,7 @@ output = world_railways_geograph.get_shortest_path(
196
226
  )
197
227
  ```
198
228
 
229
+ ### Using Geographs for Visualization
199
230
  Get a geojson line path of an output for easy visualization:
200
231
  - Note: `mapshaper.org` and `geojson.io` are good tools for visualizing geojson files
201
232
  ```py
@@ -211,6 +242,7 @@ output = marnet_geograph.get_shortest_path(
211
242
  get_line_path(output, filename='output.geojson')
212
243
  ```
213
244
 
245
+ ### Custom Graphs and Geographs
214
246
  Modify an existing geograph: See the notebook [here](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/geograph_modifications.ipynb)
215
247
 
216
248
 
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
12
12
 
13
13
  [project]
14
14
  name = "scgraph"
15
- version = "2.8.0"
15
+ version = "2.8.2"
16
16
  description = "Determine an approximate route between two points on earth."
17
17
  authors = [
18
18
  {name="Connor Makowski", email="conmak@mit.edu"}
@@ -18,34 +18,62 @@ Low Level: https://connor-makowski.github.io/scgraph/scgraph/core.html
18
18
 
19
19
  ## Key Features
20
20
 
21
- - Calculate the shortest path between two points on earth using a latitude / longitude pair
22
- - Inputs:
23
- - A latitude / longitude pair for the origin
24
- - A latitude / longitude pair for the destination
25
- - Calculation:
26
- - Algorithms:
27
- - Dijkstra's algorithm (Modified for sparse networks)
28
- - Modified to support sparse network data structures
29
- - Modified Sparse Dijkstra algorithm
30
- - Modified for O((n+m)log(n)) performance where n is the number of nodes and m is the number of edges
31
- - Uses a priority queue to improve performance on large graphs
32
- - A* algorithm (Extension of the Modified Sparse Dijkstra)
33
- - Uses a heuristic function to improve performance on large graphs
34
- - Note: The heuristic function is optional and defaults to Dijkstra's algorithm
35
- - Possible future support for other algorithms
36
- - Distances:
37
- - Uses the [haversine formula](https://en.wikipedia.org/wiki/Haversine_formula) to calculate the distance between two points on earth
38
- - Returns:
39
- - `path`:
40
- - A list of dictionaries (`latitude` and `longitude`) that make up the shortest path
41
- - `length`:
42
- - The distance in kilometers between the two points
43
- - Antimeridian support
44
- - Arbitrary start and end points
45
- - Arbitrary network data sets
46
- - Grid based graphs
47
- - Cached shortest path calculations for very fast repetative calculations to or from the same point in a graph.
48
- - Note: Geographs are not yet supported for this feature
21
+ - `GeoGraph`s:
22
+ - A geographic graph data structure that allows for the calculation of shortest paths between two points on earth
23
+ - Uses latitude / longitude pairs to represent points on earth
24
+ - Supports maritime, rail, road and other geographic networks
25
+ - Uses a sparse network data structure to represent the graph
26
+ - How to use it - Calculate the shortest path between two points on earth
27
+ - Inputs:
28
+ - A latitude / longitude pair for the origin
29
+ - A latitude / longitude pair for the destination
30
+ - Calculation:
31
+ - Algorithms:
32
+ - Dijkstra's algorithm
33
+ - Modified to support sparse network data structures
34
+ - Modified Dijkstra algorithm
35
+ - Modified for O((n+m)log(n)) performance where n is the number of nodes and m is the number of edges
36
+ - Uses a priority queue and other improvements to run fast on large graphs
37
+ - A* algorithm (Extension of the Modified Dijkstra)
38
+ - Uses a heuristic function to improve performance on large graphs
39
+ - Possible future support for other algorithms
40
+ - Returns:
41
+ - `path`:
42
+ - A list of lists `[latitude, longitude]` that make up the shortest path
43
+ - `length`:
44
+ - The distance (in the units requested) between the two points
45
+ - Precompiled Geographs offer Antimeridian support
46
+ - Arbitrary start and end points are supported
47
+ - Start and end points do not need to be in the graph
48
+ - `GridGraph`s:
49
+ - A grid based graph data structure that allows for the calculation of shortest paths between two points on a grid
50
+ - Supports arbitrary grid sizes and blockages
51
+ - Uses a sparse network data structure to represent the graph
52
+ - How to use it - Calculate the shortest path between two points on a grid
53
+ - Inputs:
54
+ - A (x,y) coordinate on the grid for the origin
55
+ - A (x,y) coordinate on the grid for the destination
56
+ - Calculation:
57
+ - Algorithms:
58
+ - Dijkstra's algorithm
59
+ - Modified Dijkstra algorithm
60
+ - A* algorithm (Extension of the Modified Dijkstra)
61
+ - Returns:
62
+ - `length`:
63
+ - The distance between the two points on the grid
64
+ - `coordinate_path`:
65
+ - A list of dicts `{"x": x, "y": y}` representing the path taken through the grid
66
+ - Arbitrary start and end points are supported
67
+ - Start and end points do not need to be in the graph
68
+ - Arbitrary connection matricies are supported
69
+ - Cardinal connections (up, down, left, right) and diagonal connections (up-left, up-right, down-left, down-right) are used by default
70
+ - Custom connection matricies can be used to change the connections between grid items
71
+ - Cached shortest path calculations can be used for very fast repetative calculations to or from the same point in a GridGraph.
72
+ - Other Useful Features:
73
+ - Graph
74
+ - A low level graph object that has methods for validating graphs, calculating shortest paths, and more
75
+ - CacheGraphs
76
+ - A graph extension that caches spanning trees for fast shortest path calculations on repeat calls from the same origin node
49
77
 
50
78
 
51
79
  ## Setup
@@ -69,7 +97,7 @@ pip install scgraph
69
97
 
70
98
  # Getting Started
71
99
 
72
- ## Basic Usage
100
+ ## Basic Geograph Usage
73
101
 
74
102
  Get the shortest path between two points on earth using a latitude / longitude pair
75
103
  In this case, calculate the shortest maritime path between Shanghai, China and Savannah, Georgia, USA.
@@ -88,7 +116,7 @@ output = marnet_geograph.get_shortest_path(
88
116
  print('Length: ',output['length']) #=> Length: 19596.4653
89
117
  ```
90
118
 
91
- In the above example, the `output` variable is a dictionary with three keys: `length` and `coordinate_path`.
119
+ In the above example, the `output` variable is a dictionary with two keys: `length` and `coordinate_path`.
92
120
 
93
121
  - `length`: The distance between the passed origin and destination when traversing the graph along the shortest path
94
122
  - Notes:
@@ -138,10 +166,10 @@ For more examples including viewing the output on a map, see the [example notebo
138
166
  ## GridGraph usage
139
167
 
140
168
  Example:
141
- - Create a grid of 20x100 cells.
169
+ - Create a grid of 20x20 cells.
142
170
  - This creates a grid based graph with connections to all 8 neighbors for each grid item.
143
171
  - Each grid item has 4 cardinal connections at length 1 and 4 diagonal connections at length sqrt(2)
144
- - Create a wall from (10,5) to (10,99).
172
+ - Create a wall from (10,5) to (10,19).
145
173
  - This would foce any path to go to the bottom of the graph to get around the wall.
146
174
  - Get the shortest path between (2,10) and (18,10)
147
175
  - Note: The length of this path should be 16 without the wall and 20.9704 with the wall.
@@ -180,6 +208,8 @@ print(output)
180
208
 
181
209
  ## Advanced Usage
182
210
 
211
+ ### Using scgraph_data geographs
212
+
183
213
  Using `scgraph_data` geographs:
184
214
  - Note: Make sure to install the `scgraph_data` package before using these geographs
185
215
  ```py
@@ -197,6 +227,7 @@ output = world_railways_geograph.get_shortest_path(
197
227
  )
198
228
  ```
199
229
 
230
+ ### Using Geographs for Visualization
200
231
  Get a geojson line path of an output for easy visualization:
201
232
  - Note: `mapshaper.org` and `geojson.io` are good tools for visualizing geojson files
202
233
  ```py
@@ -212,6 +243,7 @@ output = marnet_geograph.get_shortest_path(
212
243
  get_line_path(output, filename='output.geojson')
213
244
  ```
214
245
 
246
+ ### Custom Graphs and Geographs
215
247
  Modify an existing geograph: See the notebook [here](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/geograph_modifications.ipynb)
216
248
 
217
249
 
@@ -370,6 +370,16 @@ class GridGraph:
370
370
  "No valid adjacent node with connections found for the given coordinates"
371
371
  )
372
372
  return closest_node_id, closest_distance
373
+
374
+ def format_coordinate(self, cooinate_dict, output_coorinate_path):
375
+ if output_coorinate_path == "list_of_tuples":
376
+ return (cooinate_dict["x"], cooinate_dict["y"])
377
+ elif output_coorinate_path == "list_of_lists":
378
+ return [cooinate_dict["x"], cooinate_dict["y"]]
379
+ elif output_coordinate_path == "list_of_dicts":
380
+ return {"x": cooinate_dict["x"], "y": cooinate_dict["y"]}
381
+ else:
382
+ raise ValueError("Invalid output_coordinate_path format")
373
383
 
374
384
  def get_shortest_path(
375
385
  self,
@@ -487,13 +497,11 @@ class GridGraph:
487
497
  output["path"], output_coordinate_path
488
498
  )
489
499
  if origin_distance > 0:
490
- output["coordinate_path"] = [origin_node] + output[
491
- "coordinate_path"
492
- ]
500
+ output["coordinate_path"] = [self.format_coordinate(origin_node, output_coordinate_path)] + output["coordinate_path"]
493
501
  output["path"] = [-1] + output["path"]
494
502
  output["length"] += origin_distance
495
503
  if destination_distance > 0:
496
- output["coordinate_path"].append(destination_node)
504
+ output["coordinate_path"].append(self.format_coordinate(destination_node, output_coordinate_path))
497
505
  output["path"].append(-1)
498
506
  output["length"] += destination_distance
499
507
  if not output_path:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scgraph
3
- Version: 2.8.0
3
+ Version: 2.8.2
4
4
  Summary: Determine an approximate route between two points on earth.
5
5
  Author-email: Connor Makowski <conmak@mit.edu>
6
6
  Project-URL: Homepage, https://github.com/connor-makowski/scgraph
@@ -33,34 +33,62 @@ Low Level: https://connor-makowski.github.io/scgraph/scgraph/core.html
33
33
 
34
34
  ## Key Features
35
35
 
36
- - Calculate the shortest path between two points on earth using a latitude / longitude pair
37
- - Inputs:
38
- - A latitude / longitude pair for the origin
39
- - A latitude / longitude pair for the destination
40
- - Calculation:
41
- - Algorithms:
42
- - Dijkstra's algorithm (Modified for sparse networks)
43
- - Modified to support sparse network data structures
44
- - Modified Sparse Dijkstra algorithm
45
- - Modified for O((n+m)log(n)) performance where n is the number of nodes and m is the number of edges
46
- - Uses a priority queue to improve performance on large graphs
47
- - A* algorithm (Extension of the Modified Sparse Dijkstra)
48
- - Uses a heuristic function to improve performance on large graphs
49
- - Note: The heuristic function is optional and defaults to Dijkstra's algorithm
50
- - Possible future support for other algorithms
51
- - Distances:
52
- - Uses the [haversine formula](https://en.wikipedia.org/wiki/Haversine_formula) to calculate the distance between two points on earth
53
- - Returns:
54
- - `path`:
55
- - A list of dictionaries (`latitude` and `longitude`) that make up the shortest path
56
- - `length`:
57
- - The distance in kilometers between the two points
58
- - Antimeridian support
59
- - Arbitrary start and end points
60
- - Arbitrary network data sets
61
- - Grid based graphs
62
- - Cached shortest path calculations for very fast repetative calculations to or from the same point in a graph.
63
- - Note: Geographs are not yet supported for this feature
36
+ - `GeoGraph`s:
37
+ - A geographic graph data structure that allows for the calculation of shortest paths between two points on earth
38
+ - Uses latitude / longitude pairs to represent points on earth
39
+ - Supports maritime, rail, road and other geographic networks
40
+ - Uses a sparse network data structure to represent the graph
41
+ - How to use it - Calculate the shortest path between two points on earth
42
+ - Inputs:
43
+ - A latitude / longitude pair for the origin
44
+ - A latitude / longitude pair for the destination
45
+ - Calculation:
46
+ - Algorithms:
47
+ - Dijkstra's algorithm
48
+ - Modified to support sparse network data structures
49
+ - Modified Dijkstra algorithm
50
+ - Modified for O((n+m)log(n)) performance where n is the number of nodes and m is the number of edges
51
+ - Uses a priority queue and other improvements to run fast on large graphs
52
+ - A* algorithm (Extension of the Modified Dijkstra)
53
+ - Uses a heuristic function to improve performance on large graphs
54
+ - Possible future support for other algorithms
55
+ - Returns:
56
+ - `path`:
57
+ - A list of lists `[latitude, longitude]` that make up the shortest path
58
+ - `length`:
59
+ - The distance (in the units requested) between the two points
60
+ - Precompiled Geographs offer Antimeridian support
61
+ - Arbitrary start and end points are supported
62
+ - Start and end points do not need to be in the graph
63
+ - `GridGraph`s:
64
+ - A grid based graph data structure that allows for the calculation of shortest paths between two points on a grid
65
+ - Supports arbitrary grid sizes and blockages
66
+ - Uses a sparse network data structure to represent the graph
67
+ - How to use it - Calculate the shortest path between two points on a grid
68
+ - Inputs:
69
+ - A (x,y) coordinate on the grid for the origin
70
+ - A (x,y) coordinate on the grid for the destination
71
+ - Calculation:
72
+ - Algorithms:
73
+ - Dijkstra's algorithm
74
+ - Modified Dijkstra algorithm
75
+ - A* algorithm (Extension of the Modified Dijkstra)
76
+ - Returns:
77
+ - `length`:
78
+ - The distance between the two points on the grid
79
+ - `coordinate_path`:
80
+ - A list of dicts `{"x": x, "y": y}` representing the path taken through the grid
81
+ - Arbitrary start and end points are supported
82
+ - Start and end points do not need to be in the graph
83
+ - Arbitrary connection matricies are supported
84
+ - Cardinal connections (up, down, left, right) and diagonal connections (up-left, up-right, down-left, down-right) are used by default
85
+ - Custom connection matricies can be used to change the connections between grid items
86
+ - Cached shortest path calculations can be used for very fast repetative calculations to or from the same point in a GridGraph.
87
+ - Other Useful Features:
88
+ - Graph
89
+ - A low level graph object that has methods for validating graphs, calculating shortest paths, and more
90
+ - CacheGraphs
91
+ - A graph extension that caches spanning trees for fast shortest path calculations on repeat calls from the same origin node
64
92
 
65
93
 
66
94
  ## Setup
@@ -84,7 +112,7 @@ pip install scgraph
84
112
 
85
113
  # Getting Started
86
114
 
87
- ## Basic Usage
115
+ ## Basic Geograph Usage
88
116
 
89
117
  Get the shortest path between two points on earth using a latitude / longitude pair
90
118
  In this case, calculate the shortest maritime path between Shanghai, China and Savannah, Georgia, USA.
@@ -103,7 +131,7 @@ output = marnet_geograph.get_shortest_path(
103
131
  print('Length: ',output['length']) #=> Length: 19596.4653
104
132
  ```
105
133
 
106
- In the above example, the `output` variable is a dictionary with three keys: `length` and `coordinate_path`.
134
+ In the above example, the `output` variable is a dictionary with two keys: `length` and `coordinate_path`.
107
135
 
108
136
  - `length`: The distance between the passed origin and destination when traversing the graph along the shortest path
109
137
  - Notes:
@@ -153,10 +181,10 @@ For more examples including viewing the output on a map, see the [example notebo
153
181
  ## GridGraph usage
154
182
 
155
183
  Example:
156
- - Create a grid of 20x100 cells.
184
+ - Create a grid of 20x20 cells.
157
185
  - This creates a grid based graph with connections to all 8 neighbors for each grid item.
158
186
  - Each grid item has 4 cardinal connections at length 1 and 4 diagonal connections at length sqrt(2)
159
- - Create a wall from (10,5) to (10,99).
187
+ - Create a wall from (10,5) to (10,19).
160
188
  - This would foce any path to go to the bottom of the graph to get around the wall.
161
189
  - Get the shortest path between (2,10) and (18,10)
162
190
  - Note: The length of this path should be 16 without the wall and 20.9704 with the wall.
@@ -195,6 +223,8 @@ print(output)
195
223
 
196
224
  ## Advanced Usage
197
225
 
226
+ ### Using scgraph_data geographs
227
+
198
228
  Using `scgraph_data` geographs:
199
229
  - Note: Make sure to install the `scgraph_data` package before using these geographs
200
230
  ```py
@@ -212,6 +242,7 @@ output = world_railways_geograph.get_shortest_path(
212
242
  )
213
243
  ```
214
244
 
245
+ ### Using Geographs for Visualization
215
246
  Get a geojson line path of an output for easy visualization:
216
247
  - Note: `mapshaper.org` and `geojson.io` are good tools for visualizing geojson files
217
248
  ```py
@@ -227,6 +258,7 @@ output = marnet_geograph.get_shortest_path(
227
258
  get_line_path(output, filename='output.geojson')
228
259
  ```
229
260
 
261
+ ### Custom Graphs and Geographs
230
262
  Modify an existing geograph: See the notebook [here](https://colab.research.google.com/github/connor-makowski/scgraph/blob/main/examples/geograph_modifications.ipynb)
231
263
 
232
264
 
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = scgraph
3
- version = 2.8.0
3
+ version = 2.8.2
4
4
  description_file = README.md
5
5
 
6
6
  [options]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes