edsger 0.1.5__tar.gz → 0.1.6__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 (92) hide show
  1. {edsger-0.1.5 → edsger-0.1.6}/.pre-commit-config.yaml +11 -1
  2. {edsger-0.1.5 → edsger-0.1.6}/PKG-INFO +124 -2
  3. {edsger-0.1.5 → edsger-0.1.6}/README.md +123 -1
  4. edsger-0.1.6/clean_build.sh +29 -0
  5. edsger-0.1.6/docs/TYPING.md +107 -0
  6. edsger-0.1.6/docs/source/api.md +553 -0
  7. edsger-0.1.6/docs/source/assets/dijkstra_benchmark_comparison.png +0 -0
  8. edsger-0.1.6/docs/source/index.md +92 -0
  9. {edsger-0.1.5 → edsger-0.1.6}/docs/source/installation.md +13 -1
  10. {edsger-0.1.5 → edsger-0.1.6}/docs/source/quickstart.md +166 -17
  11. {edsger-0.1.5 → edsger-0.1.6}/pyproject.toml +3 -0
  12. edsger-0.1.6/pyrightconfig.json +82 -0
  13. {edsger-0.1.5 → edsger-0.1.6}/requirements-dev.txt +5 -0
  14. edsger-0.1.6/scripts/benchmark_dimacs_USA_linux.json +84 -0
  15. {edsger-0.1.5 → edsger-0.1.6}/scripts/benchmark_dimacs_USA_windows.json +29 -29
  16. edsger-0.1.6/setup.py +234 -0
  17. edsger-0.1.6/src/edsger/_version.py +1 -0
  18. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/bellman_ford.c +1344 -967
  19. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/bellman_ford.pyx +7 -0
  20. edsger-0.1.6/src/edsger/bfs.c +33575 -0
  21. edsger-0.1.6/src/edsger/bfs.pyx +243 -0
  22. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/commons.c +283 -278
  23. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/commons.pyx +7 -0
  24. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/dijkstra.c +2417 -1856
  25. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/dijkstra.pyx +7 -0
  26. edsger-0.1.6/src/edsger/graph_importer.py +340 -0
  27. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/networks.py +4 -2
  28. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/path.py +676 -129
  29. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/path_tracking.c +407 -301
  30. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/path_tracking.pyx +7 -0
  31. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/pq_4ary_dec_0b.c +1159 -1015
  32. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/pq_4ary_dec_0b.pyx +7 -0
  33. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/spiess_florian.c +1394 -1139
  34. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/spiess_florian.pyx +7 -0
  35. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/star.c +1224 -766
  36. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/star.pyx +7 -0
  37. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/utils.py +9 -8
  38. {edsger-0.1.5 → edsger-0.1.6}/src/edsger.egg-info/PKG-INFO +124 -2
  39. {edsger-0.1.5 → edsger-0.1.6}/src/edsger.egg-info/SOURCES.txt +12 -0
  40. edsger-0.1.6/tests/test_arrow_backend.py +404 -0
  41. edsger-0.1.6/tests/test_backend_selection.py +356 -0
  42. {edsger-0.1.5 → edsger-0.1.6}/tests/test_bellman_ford.py +336 -6
  43. edsger-0.1.6/tests/test_bfs.py +691 -0
  44. edsger-0.1.6/tests/test_dataframe_integration.py +429 -0
  45. edsger-0.1.6/tests/test_graph_importer.py +445 -0
  46. {edsger-0.1.5 → edsger-0.1.6}/tests/test_path.py +357 -23
  47. edsger-0.1.6/tests/test_polars_support.py +330 -0
  48. edsger-0.1.6/tests/test_pq_4ary_dec_0b.py +42 -0
  49. {edsger-0.1.5 → edsger-0.1.6}/tests/test_spiess_florian.py +3 -3
  50. edsger-0.1.5/docs/source/api.md +0 -248
  51. edsger-0.1.5/docs/source/assets/dijkstra_benchmark_comparison.png +0 -0
  52. edsger-0.1.5/docs/source/index.md +0 -82
  53. edsger-0.1.5/scripts/benchmark_dimacs_USA_linux.json +0 -84
  54. edsger-0.1.5/setup.py +0 -101
  55. edsger-0.1.5/src/edsger/_version.py +0 -1
  56. edsger-0.1.5/tests/test_pq_4ary_dec_0b.py +0 -42
  57. {edsger-0.1.5 → edsger-0.1.6}/.github/workflows/docs.yml +0 -0
  58. {edsger-0.1.5 → edsger-0.1.6}/.github/workflows/publish.yml +0 -0
  59. {edsger-0.1.5 → edsger-0.1.6}/.github/workflows/tests.yml +0 -0
  60. {edsger-0.1.5 → edsger-0.1.6}/.gitignore +0 -0
  61. {edsger-0.1.5 → edsger-0.1.6}/.readthedocs.yaml +0 -0
  62. {edsger-0.1.5 → edsger-0.1.6}/AUTHORS.rst +0 -0
  63. {edsger-0.1.5 → edsger-0.1.6}/CHANGELOG.rst +0 -0
  64. {edsger-0.1.5 → edsger-0.1.6}/CONTRIBUTING.rst +0 -0
  65. {edsger-0.1.5 → edsger-0.1.6}/LICENSE +0 -0
  66. {edsger-0.1.5 → edsger-0.1.6}/MANIFEST.in +0 -0
  67. {edsger-0.1.5 → edsger-0.1.6}/docs/Makefile +0 -0
  68. {edsger-0.1.5 → edsger-0.1.6}/docs/requirements.txt +0 -0
  69. {edsger-0.1.5 → edsger-0.1.6}/docs/source/conf.py +0 -0
  70. {edsger-0.1.5 → edsger-0.1.6}/docs/source/contributing.md +0 -0
  71. {edsger-0.1.5 → edsger-0.1.6}/requirements.txt +0 -0
  72. {edsger-0.1.5 → edsger-0.1.6}/scripts/README_benchmark_os.md +0 -0
  73. {edsger-0.1.5 → edsger-0.1.6}/scripts/bellman_ford_dimacs.py +0 -0
  74. {edsger-0.1.5 → edsger-0.1.6}/scripts/benchmark_comparison_os.py +0 -0
  75. {edsger-0.1.5 → edsger-0.1.6}/scripts/compare_bellman_ford_scipy.py +0 -0
  76. {edsger-0.1.5 → edsger-0.1.6}/scripts/compare_dijkstra_scipy.py +0 -0
  77. {edsger-0.1.5 → edsger-0.1.6}/scripts/dijkstra_dimacs.py +0 -0
  78. {edsger-0.1.5 → edsger-0.1.6}/scripts/plot_benchmark_comparison.py +0 -0
  79. {edsger-0.1.5 → edsger-0.1.6}/scripts/requirements_linux.txt +0 -0
  80. {edsger-0.1.5 → edsger-0.1.6}/scripts/requirements_windows.txt +0 -0
  81. {edsger-0.1.5 → edsger-0.1.6}/setup.cfg +0 -0
  82. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/.gitignore +0 -0
  83. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/__init__.py +0 -0
  84. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/commons.pxd +0 -0
  85. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/pq_4ary_dec_0b.pxd +0 -0
  86. {edsger-0.1.5 → edsger-0.1.6}/src/edsger/prefetch_compat.h +0 -0
  87. {edsger-0.1.5 → edsger-0.1.6}/src/edsger.egg-info/dependency_links.txt +0 -0
  88. {edsger-0.1.5 → edsger-0.1.6}/src/edsger.egg-info/not-zip-safe +0 -0
  89. {edsger-0.1.5 → edsger-0.1.6}/src/edsger.egg-info/requires.txt +0 -0
  90. {edsger-0.1.5 → edsger-0.1.6}/src/edsger.egg-info/top_level.txt +0 -0
  91. {edsger-0.1.5 → edsger-0.1.6}/tests/test_dijkstra.py +0 -0
  92. {edsger-0.1.5 → edsger-0.1.6}/tests/test_path_tracking.py +0 -0
@@ -11,4 +11,14 @@ repos:
11
11
  hooks:
12
12
  - id: cython-lint
13
13
  files: '\.(pyx|pxd)$'
14
- args: [--max-line-length=88]
14
+ args: [--max-line-length=88]
15
+
16
+ - repo: local
17
+ hooks:
18
+ - id: pyright
19
+ name: pyright
20
+ entry: pyright
21
+ language: system
22
+ types: [python]
23
+ pass_filenames: false
24
+ always_run: true
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: edsger
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: Graph algorithms in Cython.
5
5
  Author-email: François Pacull <francois.pacull@architecture-performance.fr>
6
6
  Maintainer-email: François Pacull <francois.pacull@architecture-performance.fr>
@@ -48,6 +48,7 @@ Dynamic: license-file
48
48
  [![Python 3.9 | 3.10 | 3.11 | 3.12 | 3.13](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)](https://pypi.org/project/edsger/)
49
49
  [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
50
50
  [![Cython lint: cython-lint](https://img.shields.io/badge/cython--lint-enabled-brightgreen.svg)](https://github.com/MarcoGorelli/cython-lint)
51
+ [![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
51
52
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
52
53
 
53
54
  # Edsger
@@ -155,6 +156,53 @@ except ValueError as e:
155
156
 
156
157
  Error: Negative cycle detected in the graph
157
158
 
159
+ ## Breadth-First Search: Unweighted Directed Graphs
160
+
161
+ The BFS (Breadth-First Search) algorithm finds shortest paths in directed graphs where edge weights are ignored (or all edges are treated as having equal weight). It's particularly efficient for finding paths based on the minimum number of hops/edges rather than weighted distances.
162
+
163
+ ```python
164
+ from edsger.path import BFS
165
+
166
+ # Create an unweighted directed graph
167
+ edges_unweighted = pd.DataFrame({
168
+ 'tail': [0, 0, 1, 2, 2, 3],
169
+ 'head': [1, 2, 3, 3, 4, 4]
170
+ })
171
+ edges_unweighted
172
+ ```
173
+
174
+ | | tail | head |
175
+ |---:|-------:|-------:|
176
+ | 0 | 0 | 1 |
177
+ | 1 | 0 | 2 |
178
+ | 2 | 1 | 3 |
179
+ | 3 | 2 | 3 |
180
+ | 4 | 2 | 4 |
181
+ | 5 | 3 | 4 |
182
+
183
+ ```python
184
+ # Initialize BFS
185
+ bfs = BFS(edges_unweighted)
186
+
187
+ # Run BFS from vertex 0 with path tracking
188
+ predecessors = bfs.run(vertex_idx=0, path_tracking=True)
189
+ print("Predecessors:", predecessors)
190
+
191
+ # Extract the path to vertex 4
192
+ path = bfs.get_path(4)
193
+ print("Path from 0 to 4:", path)
194
+ ```
195
+
196
+ Predecessors: [-9999 0 0 1 2]
197
+ Path from 0 to 4: [4 2 0]
198
+
199
+ The BFS algorithm is ideal for directed graphs when:
200
+ - All edges should be treated equally (ignoring edge weights)
201
+ - You need to find paths with the minimum number of edges/hops
202
+ - You want the fastest path-finding algorithm for unweighted directed graphs (O(V + E) time complexity)
203
+
204
+ Note: The predecessor value -9999 indicates either the start vertex or an unreachable vertex. In the path output, vertices are listed from target to source.
205
+
158
206
  ## Installation
159
207
 
160
208
  ### Standard Installation
@@ -163,6 +211,80 @@ except ValueError as e:
163
211
  pip install edsger
164
212
  ```
165
213
 
214
+ ### Development Installation
215
+
216
+ For development work, clone the repository and install in development mode:
217
+
218
+ ```bash
219
+ git clone https://github.com/aetperf/Edsger.git
220
+ cd Edsger
221
+ pip install -r requirements-dev.txt
222
+ pip install -e .
223
+ ```
224
+
225
+ ## Development
226
+
227
+ This project uses several development tools to ensure code quality:
228
+
229
+ ### Type Checking
230
+
231
+ We use [Pyright](https://github.com/microsoft/pyright) for static type checking:
232
+
233
+ ```bash
234
+ # Run type checking
235
+ make typecheck
236
+
237
+ # Or directly with pyright
238
+ pyright
239
+ ```
240
+
241
+ For more details on type checking configuration and gradual typing strategy, see [TYPING.md](TYPING.md).
242
+
243
+ ### Running Tests
244
+
245
+ ```bash
246
+ # Run all tests
247
+ make test
248
+
249
+ # Run with coverage
250
+ make coverage
251
+ ```
252
+
253
+ ### Code Formatting and Linting
254
+
255
+ ```bash
256
+ # Format code with black
257
+ make format
258
+
259
+ # Check code style
260
+ make lint
261
+ ```
262
+
263
+ ### Pre-commit Hooks
264
+
265
+ This project uses pre-commit hooks to maintain code quality. The hooks behave differently based on the branch:
266
+
267
+ - **Protected branches (main, release*)**: All hooks run including pyright type checking
268
+ - **Feature branches**: Only formatting hooks run (black, cython-lint) for faster commits
269
+ - Run `make typecheck` or `pre-commit run --all-files` to manually check types before merging
270
+
271
+ ```bash
272
+ # Install pre-commit hooks
273
+ pre-commit install
274
+
275
+ # Run all hooks manually
276
+ pre-commit run --all-files
277
+
278
+ # Skip specific hooks if needed
279
+ SKIP=pyright git commit -m "your message"
280
+ ```
281
+
282
+ ### Available Make Commands
283
+
284
+ ```bash
285
+ make help # Show all available commands
286
+ ```
287
+
166
288
  ## Why Use Edsger?
167
289
 
168
290
  Edsger is designed to be **dataframe-friendly**, providing seamless integration with pandas workflows for graph algorithms. Also it is rather efficient on Linux. Our benchmarks on the USA road network (23.9M vertices, 57.7M edges) demonstrate nice performance:
@@ -179,4 +301,4 @@ Edsger is licensed under the MIT License. See the LICENSE file for more details.
179
301
 
180
302
  ## Contact
181
303
 
182
- For any questions or inquiries, please contact François Pacull at [francois.pacull@architecture-performance.fr](mailto:francois.pacull@architecture-performance.fr).
304
+ For any questions or inquiries, please contact me at [francois.pacull@architecture-performance.fr](mailto:francois.pacull@architecture-performance.fr).
@@ -7,6 +7,7 @@
7
7
  [![Python 3.9 | 3.10 | 3.11 | 3.12 | 3.13](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)](https://pypi.org/project/edsger/)
8
8
  [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
9
9
  [![Cython lint: cython-lint](https://img.shields.io/badge/cython--lint-enabled-brightgreen.svg)](https://github.com/MarcoGorelli/cython-lint)
10
+ [![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
10
11
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
12
 
12
13
  # Edsger
@@ -114,6 +115,53 @@ except ValueError as e:
114
115
 
115
116
  Error: Negative cycle detected in the graph
116
117
 
118
+ ## Breadth-First Search: Unweighted Directed Graphs
119
+
120
+ The BFS (Breadth-First Search) algorithm finds shortest paths in directed graphs where edge weights are ignored (or all edges are treated as having equal weight). It's particularly efficient for finding paths based on the minimum number of hops/edges rather than weighted distances.
121
+
122
+ ```python
123
+ from edsger.path import BFS
124
+
125
+ # Create an unweighted directed graph
126
+ edges_unweighted = pd.DataFrame({
127
+ 'tail': [0, 0, 1, 2, 2, 3],
128
+ 'head': [1, 2, 3, 3, 4, 4]
129
+ })
130
+ edges_unweighted
131
+ ```
132
+
133
+ | | tail | head |
134
+ |---:|-------:|-------:|
135
+ | 0 | 0 | 1 |
136
+ | 1 | 0 | 2 |
137
+ | 2 | 1 | 3 |
138
+ | 3 | 2 | 3 |
139
+ | 4 | 2 | 4 |
140
+ | 5 | 3 | 4 |
141
+
142
+ ```python
143
+ # Initialize BFS
144
+ bfs = BFS(edges_unweighted)
145
+
146
+ # Run BFS from vertex 0 with path tracking
147
+ predecessors = bfs.run(vertex_idx=0, path_tracking=True)
148
+ print("Predecessors:", predecessors)
149
+
150
+ # Extract the path to vertex 4
151
+ path = bfs.get_path(4)
152
+ print("Path from 0 to 4:", path)
153
+ ```
154
+
155
+ Predecessors: [-9999 0 0 1 2]
156
+ Path from 0 to 4: [4 2 0]
157
+
158
+ The BFS algorithm is ideal for directed graphs when:
159
+ - All edges should be treated equally (ignoring edge weights)
160
+ - You need to find paths with the minimum number of edges/hops
161
+ - You want the fastest path-finding algorithm for unweighted directed graphs (O(V + E) time complexity)
162
+
163
+ Note: The predecessor value -9999 indicates either the start vertex or an unreachable vertex. In the path output, vertices are listed from target to source.
164
+
117
165
  ## Installation
118
166
 
119
167
  ### Standard Installation
@@ -122,6 +170,80 @@ except ValueError as e:
122
170
  pip install edsger
123
171
  ```
124
172
 
173
+ ### Development Installation
174
+
175
+ For development work, clone the repository and install in development mode:
176
+
177
+ ```bash
178
+ git clone https://github.com/aetperf/Edsger.git
179
+ cd Edsger
180
+ pip install -r requirements-dev.txt
181
+ pip install -e .
182
+ ```
183
+
184
+ ## Development
185
+
186
+ This project uses several development tools to ensure code quality:
187
+
188
+ ### Type Checking
189
+
190
+ We use [Pyright](https://github.com/microsoft/pyright) for static type checking:
191
+
192
+ ```bash
193
+ # Run type checking
194
+ make typecheck
195
+
196
+ # Or directly with pyright
197
+ pyright
198
+ ```
199
+
200
+ For more details on type checking configuration and gradual typing strategy, see [TYPING.md](TYPING.md).
201
+
202
+ ### Running Tests
203
+
204
+ ```bash
205
+ # Run all tests
206
+ make test
207
+
208
+ # Run with coverage
209
+ make coverage
210
+ ```
211
+
212
+ ### Code Formatting and Linting
213
+
214
+ ```bash
215
+ # Format code with black
216
+ make format
217
+
218
+ # Check code style
219
+ make lint
220
+ ```
221
+
222
+ ### Pre-commit Hooks
223
+
224
+ This project uses pre-commit hooks to maintain code quality. The hooks behave differently based on the branch:
225
+
226
+ - **Protected branches (main, release*)**: All hooks run including pyright type checking
227
+ - **Feature branches**: Only formatting hooks run (black, cython-lint) for faster commits
228
+ - Run `make typecheck` or `pre-commit run --all-files` to manually check types before merging
229
+
230
+ ```bash
231
+ # Install pre-commit hooks
232
+ pre-commit install
233
+
234
+ # Run all hooks manually
235
+ pre-commit run --all-files
236
+
237
+ # Skip specific hooks if needed
238
+ SKIP=pyright git commit -m "your message"
239
+ ```
240
+
241
+ ### Available Make Commands
242
+
243
+ ```bash
244
+ make help # Show all available commands
245
+ ```
246
+
125
247
  ## Why Use Edsger?
126
248
 
127
249
  Edsger is designed to be **dataframe-friendly**, providing seamless integration with pandas workflows for graph algorithms. Also it is rather efficient on Linux. Our benchmarks on the USA road network (23.9M vertices, 57.7M edges) demonstrate nice performance:
@@ -138,4 +260,4 @@ Edsger is licensed under the MIT License. See the LICENSE file for more details.
138
260
 
139
261
  ## Contact
140
262
 
141
- For any questions or inquiries, please contact François Pacull at [francois.pacull@architecture-performance.fr](mailto:francois.pacull@architecture-performance.fr).
263
+ For any questions or inquiries, please contact me at [francois.pacull@architecture-performance.fr](mailto:francois.pacull@architecture-performance.fr).
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+
3
+ # Clean build script for Edsger Cython project
4
+ # Use this when making significant changes to ensure clean rebuild
5
+
6
+ echo "Cleaning build artifacts..."
7
+
8
+ # Remove compiled Cython C files
9
+ find src/ -name "*.c" -delete
10
+ echo "✓ Removed generated C files"
11
+
12
+ # Remove compiled shared libraries
13
+ find src/ -name "*.so" -delete
14
+ echo "✓ Removed shared libraries"
15
+
16
+ # Remove build directory
17
+ rm -rf build/
18
+ echo "✓ Removed build directory"
19
+
20
+ # Remove Python cache
21
+ find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null
22
+ find . -name "*.pyc" -delete 2>/dev/null
23
+ echo "✓ Removed Python cache"
24
+
25
+ # Remove Cython HTML annotation files (if any)
26
+ find . -name "*.html" -path "*/build/*" -delete 2>/dev/null
27
+
28
+ echo "Clean complete! Ready for fresh build."
29
+ echo "Run: python setup.py build_ext --inplace"
@@ -0,0 +1,107 @@
1
+ # Type Checking with Pyright
2
+
3
+ This project uses [Pyright](https://github.com/microsoft/pyright) for static type checking.
4
+
5
+ ## Setup
6
+
7
+ 1. **Install dependencies**:
8
+ ```bash
9
+ pip install -r requirements-dev.txt
10
+ ```
11
+
12
+ 2. **Run type checking**:
13
+ ```bash
14
+ # Basic mode (default)
15
+ make typecheck
16
+ # or directly
17
+ pyright
18
+
19
+ # Strict mode
20
+ make typecheck-strict
21
+ ```
22
+
23
+ ## Configuration
24
+
25
+ The type checking configuration is defined in `pyrightconfig.json`. The project currently uses **basic** type checking mode to allow for gradual type hint adoption.
26
+
27
+ ## Current Status
28
+
29
+ The project is in the process of adding type hints. Currently:
30
+
31
+ - **Type checking mode**: Basic
32
+ - **Coverage**: Minimal type hints in Python files
33
+ - **Cython files**: Excluded from type checking (`.pyx` and `.pxd` files)
34
+
35
+ ## Known Issues
36
+
37
+ ### Import Resolution
38
+ Some optional dependencies may show import warnings:
39
+ - `scipy` - Used in tests and scripts
40
+ - `loguru` - Used in scripts
41
+ - `graph_tool` - Optional dependency for benchmarks
42
+ - `networkit` - Optional dependency for benchmarks
43
+
44
+ These can be safely ignored if you're not using these features.
45
+
46
+ ### Cython Integration
47
+ Cython-generated modules may show as missing imports. These are expected:
48
+ - Imports from `.pyx` files will show warnings
49
+ - This is normal as Pyright cannot analyze Cython files directly
50
+
51
+ ### Test Files
52
+ Some test files import functions directly from Cython modules that are not visible to Pyright.
53
+
54
+ ## Adding Type Hints
55
+
56
+ When adding type hints to the project:
57
+
58
+ 1. **Start with function signatures**:
59
+ ```python
60
+ def compute_path(edges: pd.DataFrame, source: int) -> np.ndarray:
61
+ ...
62
+ ```
63
+
64
+ 2. **Use type aliases for clarity**:
65
+ ```python
66
+ from typing import TypeAlias
67
+
68
+ NodeID: TypeAlias = int
69
+ Weight: TypeAlias = float
70
+ ```
71
+
72
+ 3. **For Cython imports, use type ignore comments**:
73
+ ```python
74
+ from edsger.dijkstra import compute_sssp # type: ignore
75
+ ```
76
+
77
+ ## VS Code Integration
78
+
79
+ If using VS Code, the project includes `.vscode/settings.json` with appropriate configurations for Pylance/Pyright integration.
80
+
81
+ ## Pre-commit Hook
82
+
83
+ Pyright is configured as a pre-commit hook. It will run automatically before commits if you have pre-commit installed:
84
+
85
+ ```bash
86
+ pre-commit install
87
+ ```
88
+
89
+ To run manually:
90
+ ```bash
91
+ pre-commit run pyright --all-files
92
+ ```
93
+
94
+ ## Gradual Typing Strategy
95
+
96
+ The project follows a gradual typing approach:
97
+
98
+ 1. **Phase 1** (Current): Basic type checking, focus on obvious type errors
99
+ 2. **Phase 2**: Add type hints to public APIs
100
+ 3. **Phase 3**: Increase to standard mode, add more comprehensive type hints
101
+ 4. **Phase 4**: Consider strict mode for new code
102
+
103
+ ## Resources
104
+
105
+ - [Pyright Documentation](https://github.com/microsoft/pyright/blob/main/docs/configuration.md)
106
+ - [Python Type Hints](https://docs.python.org/3/library/typing.html)
107
+ - [PEP 484 - Type Hints](https://www.python.org/dev/peps/pep-0484/)