edsger 0.1.1__tar.gz → 0.1.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.
- {edsger-0.1.1 → edsger-0.1.2}/.github/workflows/publish.yml +3 -1
- {edsger-0.1.1 → edsger-0.1.2}/.github/workflows/tests.yml +8 -1
- {edsger-0.1.1 → edsger-0.1.2}/PKG-INFO +50 -1
- edsger-0.1.2/README.md +77 -0
- edsger-0.1.2/docs/source/assets/dijkstra_benchmark_comparison.png +0 -0
- edsger-0.1.2/docs/source/index.md +80 -0
- {edsger-0.1.1 → edsger-0.1.2}/docs/source/quickstart.md +36 -26
- {edsger-0.1.1 → edsger-0.1.2}/requirements-dev.txt +1 -0
- edsger-0.1.2/scripts/benchmark_comparison.py +442 -0
- {edsger-0.1.1 → edsger-0.1.2}/scripts/dijkstra_dimacs.py +4 -4
- edsger-0.1.2/scripts/requirements.txt +11 -0
- {edsger-0.1.1 → edsger-0.1.2}/setup.py +8 -1
- edsger-0.1.2/src/edsger/_version.py +1 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/commons.c +151 -147
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/dijkstra.c +1132 -1059
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/dijkstra.pyx +23 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/path_tracking.c +151 -147
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/path_tracking.pyx +2 -2
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/pq_4ary_dec_0b.c +203 -199
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/pq_4ary_dec_0b.pxd +7 -7
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/pq_4ary_dec_0b.pyx +14 -16
- edsger-0.1.2/src/edsger/prefetch_compat.h +21 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/spiess_florian.c +157 -176
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/star.c +151 -147
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/star.pyx +3 -3
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger.egg-info/PKG-INFO +50 -1
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger.egg-info/SOURCES.txt +4 -0
- edsger-0.1.1/README.md +0 -28
- edsger-0.1.1/docs/source/index.md +0 -54
- edsger-0.1.1/src/edsger/_version.py +0 -1
- {edsger-0.1.1 → edsger-0.1.2}/.github/workflows/docs.yml +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/.gitignore +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/.pre-commit-config.yaml +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/.readthedocs.yaml +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/AUTHORS.rst +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/CHANGELOG.rst +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/CONTRIBUTING.rst +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/LICENSE +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/MANIFEST.in +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/docs/Makefile +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/docs/requirements.txt +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/docs/source/api.md +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/docs/source/conf.py +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/docs/source/contributing.md +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/docs/source/installation.md +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/pyproject.toml +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/requirements.txt +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/setup.cfg +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/.gitignore +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/__init__.py +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/commons.pxd +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/commons.pyx +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/networks.py +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/path.py +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/spiess_florian.pyx +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger/utils.py +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger.egg-info/dependency_links.txt +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger.egg-info/not-zip-safe +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger.egg-info/requires.txt +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/src/edsger.egg-info/top_level.txt +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/tests/test_dijkstra.py +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/tests/test_path.py +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/tests/test_path_tracking.py +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/tests/test_pq_4ary_dec_0b.py +0 -0
- {edsger-0.1.1 → edsger-0.1.2}/tests/test_spiess_florian.py +0 -0
@@ -54,6 +54,7 @@ jobs:
|
|
54
54
|
|
55
55
|
- uses: actions/upload-artifact@v4
|
56
56
|
with:
|
57
|
+
name: cibw-sdist
|
57
58
|
path: ./dist/*.tar.gz
|
58
59
|
|
59
60
|
build_wheels:
|
@@ -95,7 +96,8 @@ jobs:
|
|
95
96
|
- name: Download all the dists
|
96
97
|
uses: actions/download-artifact@v4
|
97
98
|
with:
|
98
|
-
|
99
|
+
pattern: cibw-*
|
99
100
|
path: ./dist/
|
101
|
+
merge-multiple: true
|
100
102
|
- name: Publish distribution to PyPI
|
101
103
|
uses: pypa/gh-action-pypi-publish@release/v1
|
@@ -31,4 +31,11 @@ jobs:
|
|
31
31
|
cython-lint src/edsger/commons.pyx src/edsger/dijkstra.pyx src/edsger/path_tracking.pyx src/edsger/pq_4ary_dec_0b.pyx src/edsger/spiess_florian.pyx src/edsger/star.pyx src/edsger/commons.pxd src/edsger/pq_4ary_dec_0b.pxd
|
32
32
|
- name: Testing
|
33
33
|
run: |
|
34
|
-
python -m pytest tests
|
34
|
+
python -m pytest --cov=src/edsger --cov-report=xml tests/
|
35
|
+
- name: Upload coverage to Codecov
|
36
|
+
uses: codecov/codecov-action@v4
|
37
|
+
with:
|
38
|
+
file: ./coverage.xml
|
39
|
+
flags: unittests
|
40
|
+
name: codecov-umbrella
|
41
|
+
fail_ci_if_error: false
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: edsger
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.2
|
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>
|
@@ -41,6 +41,7 @@ Dynamic: license-file
|
|
41
41
|
|
42
42
|
|
43
43
|

|
44
|
+
[](https://codecov.io/gh/aetperf/edsger)
|
44
45
|
[](https://pypi.org/project/edsger/)
|
45
46
|
[](https://pepy.tech/project/edsger)
|
46
47
|
[](https://pypi.org/project/edsger/)
|
@@ -56,6 +57,54 @@ Welcome to our Python library for graph algorithms. So far, the library only inc
|
|
56
57
|
|
57
58
|
Documentation : [https://edsger.readthedocs.io/en/latest/](https://edsger.readthedocs.io/en/latest/)
|
58
59
|
|
60
|
+
## Small example : Dijkstra's Algorithm
|
61
|
+
|
62
|
+
To use Dijkstra's algorithm, you can import the `Dijkstra` class from the `path` module. The function takes a graph and a source node as input, and returns the shortest path from the source node to all other nodes in the graph.
|
63
|
+
|
64
|
+
```python
|
65
|
+
import pandas as pd
|
66
|
+
|
67
|
+
from edsger.path import Dijkstra
|
68
|
+
|
69
|
+
# Create a DataFrame with the edges of the graph
|
70
|
+
edges = pd.DataFrame({
|
71
|
+
'tail': [0, 0, 1, 2, 2, 3],
|
72
|
+
'head': [1, 2, 2, 3, 4, 4],
|
73
|
+
'weight': [1, 4, 2, 1.5, 3, 1]
|
74
|
+
})
|
75
|
+
edges
|
76
|
+
```
|
77
|
+
|
78
|
+
| | tail | head | weight |
|
79
|
+
|---:|-------:|-------:|---------:|
|
80
|
+
| 0 | 0 | 1 | 1.0 |
|
81
|
+
| 1 | 0 | 2 | 4.0 |
|
82
|
+
| 2 | 1 | 2 | 2.0 |
|
83
|
+
| 3 | 2 | 3 | 1.5 |
|
84
|
+
| 4 | 2 | 4 | 3.0 |
|
85
|
+
| 5 | 3 | 4 | 1.0 |
|
86
|
+
|
87
|
+
```python
|
88
|
+
# Initialize the Dijkstra object
|
89
|
+
dijkstra = Dijkstra(edges)
|
90
|
+
|
91
|
+
# Run the algorithm from a source vertex
|
92
|
+
shortest_paths = dijkstra.run(vertex_idx=0)
|
93
|
+
print("Shortest paths:", shortest_paths)
|
94
|
+
```
|
95
|
+
|
96
|
+
Shortest paths: [0. 1. 3. 4.5 5.5]
|
97
|
+
|
98
|
+
We get the shortest paths from the source node 0 to all other nodes in the graph. The output is an array with the shortest path length to each node. A path length is the sum of the weights of the edges in the path.
|
99
|
+
|
100
|
+
## Why Use Edsger?
|
101
|
+
|
102
|
+
Edsger is designed to be **dataframe-friendly**, providing seamless integration with pandas workflows for graph algorithms. Also it is rather efficient. Our benchmarks on the USA road network (23.9M vertices, 57.7M edges) demonstrate nice performance:
|
103
|
+
|
104
|
+
<img src="docs/source/assets/dijkstra_benchmark_comparison.png" alt="Dijkstra Performance Comparison" width="700">
|
105
|
+
|
106
|
+
*Benchmark performed on Intel i9-12900H laptop.*
|
107
|
+
|
59
108
|
## Contributing
|
60
109
|
|
61
110
|
We welcome contributions to the Edsger library. If you have any suggestions, bug reports, or feature requests, please open an issue on our [GitHub repository](https://github.com/aetperf/Edsger).
|
edsger-0.1.2/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
|
2
|
+

|
3
|
+
[](https://codecov.io/gh/aetperf/edsger)
|
4
|
+
[](https://pypi.org/project/edsger/)
|
5
|
+
[](https://pepy.tech/project/edsger)
|
6
|
+
[](https://pypi.org/project/edsger/)
|
7
|
+
[](https://github.com/psf/black)
|
8
|
+
[](https://github.com/MarcoGorelli/cython-lint)
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
10
|
+
|
11
|
+
# Edsger
|
12
|
+
|
13
|
+
*Graph algorithms in Cython*
|
14
|
+
|
15
|
+
Welcome to our Python library for graph algorithms. So far, the library only includes Dijkstra's algorithm but we should add a range of common path algorithms later. It is also open-source and easy to integrate with other Python libraries. To get started, simply install the library using pip, and import it into your Python project.
|
16
|
+
|
17
|
+
Documentation : [https://edsger.readthedocs.io/en/latest/](https://edsger.readthedocs.io/en/latest/)
|
18
|
+
|
19
|
+
## Small example : Dijkstra's Algorithm
|
20
|
+
|
21
|
+
To use Dijkstra's algorithm, you can import the `Dijkstra` class from the `path` module. The function takes a graph and a source node as input, and returns the shortest path from the source node to all other nodes in the graph.
|
22
|
+
|
23
|
+
```python
|
24
|
+
import pandas as pd
|
25
|
+
|
26
|
+
from edsger.path import Dijkstra
|
27
|
+
|
28
|
+
# Create a DataFrame with the edges of the graph
|
29
|
+
edges = pd.DataFrame({
|
30
|
+
'tail': [0, 0, 1, 2, 2, 3],
|
31
|
+
'head': [1, 2, 2, 3, 4, 4],
|
32
|
+
'weight': [1, 4, 2, 1.5, 3, 1]
|
33
|
+
})
|
34
|
+
edges
|
35
|
+
```
|
36
|
+
|
37
|
+
| | tail | head | weight |
|
38
|
+
|---:|-------:|-------:|---------:|
|
39
|
+
| 0 | 0 | 1 | 1.0 |
|
40
|
+
| 1 | 0 | 2 | 4.0 |
|
41
|
+
| 2 | 1 | 2 | 2.0 |
|
42
|
+
| 3 | 2 | 3 | 1.5 |
|
43
|
+
| 4 | 2 | 4 | 3.0 |
|
44
|
+
| 5 | 3 | 4 | 1.0 |
|
45
|
+
|
46
|
+
```python
|
47
|
+
# Initialize the Dijkstra object
|
48
|
+
dijkstra = Dijkstra(edges)
|
49
|
+
|
50
|
+
# Run the algorithm from a source vertex
|
51
|
+
shortest_paths = dijkstra.run(vertex_idx=0)
|
52
|
+
print("Shortest paths:", shortest_paths)
|
53
|
+
```
|
54
|
+
|
55
|
+
Shortest paths: [0. 1. 3. 4.5 5.5]
|
56
|
+
|
57
|
+
We get the shortest paths from the source node 0 to all other nodes in the graph. The output is an array with the shortest path length to each node. A path length is the sum of the weights of the edges in the path.
|
58
|
+
|
59
|
+
## Why Use Edsger?
|
60
|
+
|
61
|
+
Edsger is designed to be **dataframe-friendly**, providing seamless integration with pandas workflows for graph algorithms. Also it is rather efficient. Our benchmarks on the USA road network (23.9M vertices, 57.7M edges) demonstrate nice performance:
|
62
|
+
|
63
|
+
<img src="docs/source/assets/dijkstra_benchmark_comparison.png" alt="Dijkstra Performance Comparison" width="700">
|
64
|
+
|
65
|
+
*Benchmark performed on Intel i9-12900H laptop.*
|
66
|
+
|
67
|
+
## Contributing
|
68
|
+
|
69
|
+
We welcome contributions to the Edsger library. If you have any suggestions, bug reports, or feature requests, please open an issue on our [GitHub repository](https://github.com/aetperf/Edsger).
|
70
|
+
|
71
|
+
## License
|
72
|
+
|
73
|
+
Edsger is licensed under the MIT License. See the LICENSE file for more details.
|
74
|
+
|
75
|
+
## Contact
|
76
|
+
|
77
|
+
For any questions or inquiries, please contact François Pacull at [francois.pacull@architecture-performance.fr](mailto:francois.pacull@architecture-performance.fr).
|
Binary file
|
@@ -0,0 +1,80 @@
|
|
1
|
+
---
|
2
|
+
github_url: https://github.com/aetperf/Edsger
|
3
|
+
---
|
4
|
+
|
5
|
+
# Edsger
|
6
|
+
|
7
|
+
*Graph algorithms in Cython*
|
8
|
+
|
9
|
+
Welcome to the Edsger documentation! Edsger is a Python library for efficient graph algorithms implemented in Cython. The library currently focuses on shortest path algorithms, with Dijkstra's algorithm fully implemented and additional algorithms planned for future releases.
|
10
|
+
|
11
|
+
## Why Use Edsger?
|
12
|
+
|
13
|
+
Edsger is designed to be **dataframe-friendly**, providing seamless integration with pandas workflows for graph algorithms. Also it is rather efficient. Our benchmarks on the USA road network (23.9M vertices, 57.7M edges) demonstrate nice performance:
|
14
|
+
|
15
|
+
<img src="assets/dijkstra_benchmark_comparison.png" alt="Dijkstra Performance Comparison" width="700">
|
16
|
+
|
17
|
+
*Benchmark performed on Intel i9-12900H laptop.*
|
18
|
+
|
19
|
+
### Pandas Integration Made Simple
|
20
|
+
|
21
|
+
```python
|
22
|
+
import pandas as pd
|
23
|
+
from edsger.path import Dijkstra
|
24
|
+
|
25
|
+
# Your graph data is already in a DataFrame
|
26
|
+
edges = pd.DataFrame({
|
27
|
+
'tail': [0, 0, 1, 2],
|
28
|
+
'head': [1, 2, 2, 3],
|
29
|
+
'weight': [1.0, 2.0, 1.5, 1.0]
|
30
|
+
})
|
31
|
+
|
32
|
+
# No conversion needed - use directly!
|
33
|
+
dijkstra = Dijkstra(edges, orientation="out")
|
34
|
+
distances = dijkstra.run(vertex_idx=0)
|
35
|
+
```
|
36
|
+
|
37
|
+
## Key Features
|
38
|
+
|
39
|
+
- **Native pandas DataFrame support** - No graph object conversion required
|
40
|
+
- **High performance** - Cython implementation with aggressive optimizations
|
41
|
+
- **Memory efficient** - Optimized for large-scale real-world datasets
|
42
|
+
- **Easy integration** with NumPy and pandas workflows
|
43
|
+
- **Production ready** - Comprehensive testing across Python 3.9-3.13
|
44
|
+
|
45
|
+
## Quick Links
|
46
|
+
|
47
|
+
- [Installation](installation.md) - How to install Edsger
|
48
|
+
- [Quick Start](quickstart.md) - Get started quickly with basic examples
|
49
|
+
- [API Reference](api.md) - Complete API reference
|
50
|
+
|
51
|
+
## Table of Contents
|
52
|
+
|
53
|
+
```{toctree}
|
54
|
+
:maxdepth: 2
|
55
|
+
:caption: User Guide
|
56
|
+
|
57
|
+
installation
|
58
|
+
quickstart
|
59
|
+
```
|
60
|
+
|
61
|
+
```{toctree}
|
62
|
+
:maxdepth: 2
|
63
|
+
:caption: API Reference
|
64
|
+
|
65
|
+
api
|
66
|
+
```
|
67
|
+
|
68
|
+
```{toctree}
|
69
|
+
:maxdepth: 1
|
70
|
+
:caption: Development
|
71
|
+
|
72
|
+
contributing
|
73
|
+
```
|
74
|
+
|
75
|
+
## Indices
|
76
|
+
|
77
|
+
- {ref}`genindex`
|
78
|
+
- {ref}`modindex`
|
79
|
+
- {ref}`search`
|
80
|
+
|
@@ -15,39 +15,48 @@ Edsger expects graph data as a pandas DataFrame with the following structure:
|
|
15
15
|
|
16
16
|
Example:
|
17
17
|
```python
|
18
|
+
import pandas as pd
|
19
|
+
|
18
20
|
edges = pd.DataFrame({
|
19
21
|
'tail': [0, 0, 1, 2],
|
20
22
|
'head': [1, 2, 2, 3],
|
21
23
|
'weight': [1.0, 4.0, 2.0, 1.0]
|
22
24
|
})
|
25
|
+
edsges
|
23
26
|
```
|
24
27
|
|
28
|
+
| | tail | head | weight |
|
29
|
+
|---:|-------:|-------:|---------:|
|
30
|
+
| 0 | 0 | 1 | 1 |
|
31
|
+
| 1 | 0 | 2 | 4 |
|
32
|
+
| 2 | 1 | 2 | 2 |
|
33
|
+
| 3 | 2 | 3 | 1 |
|
34
|
+
|
35
|
+
|
25
36
|
## Dijkstra's Algorithm
|
26
37
|
|
27
38
|
To use Dijkstra's algorithm, you can import the `Dijkstra` class from the `path` module. The function takes a graph and a source node as input, and returns the shortest path from the source node to all other nodes in the graph.
|
28
39
|
|
29
40
|
```python
|
30
|
-
import pandas as pd
|
31
|
-
|
32
41
|
from edsger.path import Dijkstra
|
33
42
|
|
34
43
|
# Create a DataFrame with the edges of the graph
|
35
44
|
edges = pd.DataFrame({
|
36
45
|
'tail': [0, 0, 1, 2, 2, 3],
|
37
46
|
'head': [1, 2, 2, 3, 4, 4],
|
38
|
-
'weight': [1, 4, 2, 1, 3, 1]
|
47
|
+
'weight': [1, 4, 2, 1.5, 3, 1]
|
39
48
|
})
|
40
49
|
edges
|
41
50
|
```
|
42
51
|
|
43
|
-
| | tail | head | weight |
|
44
|
-
|---:|-------:|-------:|---------:|
|
45
|
-
| 0 | 0 | 1 |
|
46
|
-
| 1 | 0 | 2 |
|
47
|
-
| 2 | 1 | 2 |
|
48
|
-
| 3 | 2 | 3 |
|
49
|
-
| 4 | 2 | 4 |
|
50
|
-
| 5 | 3 | 4 |
|
52
|
+
| | tail | head | weight |
|
53
|
+
|---:|-------:|-------:|---------:|
|
54
|
+
| 0 | 0 | 1 | 1.0 |
|
55
|
+
| 1 | 0 | 2 | 4.0 |
|
56
|
+
| 2 | 1 | 2 | 2.0 |
|
57
|
+
| 3 | 2 | 3 | 1.5 |
|
58
|
+
| 4 | 2 | 4 | 3.0 |
|
59
|
+
| 5 | 3 | 4 | 1.0 |
|
51
60
|
|
52
61
|
|
53
62
|
```python
|
@@ -59,7 +68,7 @@ shortest_paths = dijkstra.run(vertex_idx=0)
|
|
59
68
|
print("Shortest paths:", shortest_paths)
|
60
69
|
```
|
61
70
|
|
62
|
-
Shortest paths: [0.
|
71
|
+
Shortest paths: [0. 1. 3. 4.5 5.5]
|
63
72
|
|
64
73
|
We get the shortest paths from the source node 0 to all other nodes in the graph. The output is an array with the shortest path length to each node. A path length is the sum of the weights of the edges in the path.
|
65
74
|
|
@@ -69,9 +78,9 @@ It is also possible to use a graph with different column names for the tail, hea
|
|
69
78
|
other_edges = pd.DataFrame({
|
70
79
|
'from': [0, 0, 1, 2, 2, 3],
|
71
80
|
'to': [1, 2, 2, 3, 4, 4],
|
72
|
-
'travel_time': [1, 4, 2, 1, 3, 1]
|
81
|
+
'travel_time': [1, 4, 2, 1.5, 3, 1]
|
73
82
|
})
|
74
|
-
other_dijkstra = Dijkstra(
|
83
|
+
other_dijkstra = Dijkstra(other_edges, tail='from', head='to', weight='travel_time')
|
75
84
|
```
|
76
85
|
|
77
86
|
### Orientation
|
@@ -98,7 +107,7 @@ shortest_paths = dijkstra.run(vertex_idx=4)
|
|
98
107
|
print("Shortest paths:", shortest_paths)
|
99
108
|
```
|
100
109
|
|
101
|
-
Shortest paths: [5. 4. 2. 1.
|
110
|
+
Shortest paths: [5.5 4.5 2.5 1. 0. ]
|
102
111
|
|
103
112
|
### Check Edges
|
104
113
|
|
@@ -131,7 +140,7 @@ SHIFT = 1000
|
|
131
140
|
shifted_edges = pd.DataFrame({
|
132
141
|
'tail': [0, 0, 1, 2, 2, 3],
|
133
142
|
'head': [1, 2, 2, 3, 4, 4],
|
134
|
-
'weight': [1, 4, 2, 1, 3, 1]
|
143
|
+
'weight': [1, 4, 2, 1.5, 3, 1]
|
135
144
|
})
|
136
145
|
shifted_edges["tail"] += SHIFT
|
137
146
|
shifted_edges["head"] += SHIFT
|
@@ -140,9 +149,9 @@ shifted_edges.head(3)
|
|
140
149
|
|
141
150
|
| | tail | head | weight |
|
142
151
|
|---:|-------:|-------:|---------:|
|
143
|
-
| 0 | 1000 | 1001 |
|
144
|
-
| 1 | 1000 | 1002 |
|
145
|
-
| 2 | 1001 | 1002 |
|
152
|
+
| 0 | 1000 | 1001 | 1.0 |
|
153
|
+
| 1 | 1000 | 1002 | 4.0 |
|
154
|
+
| 2 | 1001 | 1002 | 2.0 |
|
146
155
|
|
147
156
|
|
148
157
|
|
@@ -152,13 +161,14 @@ shortest_paths = dijkstra.run(vertex_idx=0 + SHIFT)
|
|
152
161
|
print("Shortest paths:", shortest_paths)
|
153
162
|
```
|
154
163
|
|
155
|
-
Shortest paths: [inf inf inf ...
|
164
|
+
Shortest paths: [inf inf inf ... 3. 4.5 5.5]
|
156
165
|
|
157
166
|
```python
|
158
167
|
shortest_paths[-5:]
|
159
168
|
```
|
160
169
|
|
161
|
-
array([0
|
170
|
+
array([0. , 1. , 3. , 4.5, 5.5])
|
171
|
+
|
162
172
|
|
163
173
|
### Run Method Options
|
164
174
|
|
@@ -210,11 +220,11 @@ shortest_paths
|
|
210
220
|
|
211
221
|
| vertex_idx | path_length |
|
212
222
|
|-------------:|--------------:|
|
213
|
-
| 0 |
|
214
|
-
| 1 |
|
215
|
-
| 2 |
|
216
|
-
| 3 |
|
217
|
-
| 4 |
|
223
|
+
| 0 | 5.5 |
|
224
|
+
| 1 | 4.5 |
|
225
|
+
| 2 | 2.5 |
|
226
|
+
| 3 | 1.0 |
|
227
|
+
| 4 | 0.0 |
|
218
228
|
|
219
229
|
|
220
230
|
- `heap_length_ratio` : float, optional (default=1.0)
|