Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "multimodalrouter"
version = "0.1.10"
version = "0.1.11"
description = "A graph-based routing library for dynamic routing."
readme = "README.md"
license = { file = "LICENSE.md" }
Expand Down
13 changes: 7 additions & 6 deletions src/multimodalrouter/graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .dataclasses import Hub, EdgeMetadata, OptimizationMetric, Route, Filter, VerboseRoute, PathNode
from threading import Lock
from collections import deque
from itertools import count


class RouteGraph:
Expand Down Expand Up @@ -349,8 +350,8 @@ def _dijkstra_single_source(
max_segments: int,
custom_filter: Filter | None,
):

pq: list[tuple[float, str, PathNode, EdgeMetadata]] = []
counter = count()
pq: list[tuple[float, int, PathNode, EdgeMetadata]] = []

start_metrics = EdgeMetadata()
start_path = PathNode(
Expand All @@ -360,7 +361,7 @@ def _dijkstra_single_source(
prev=None,
)

heapq.heappush(pq, (0.0, start_id, start_path, start_metrics))
heapq.heappush(pq, (0.0, next(counter), start_path, start_metrics))

# visited[(hub_id, path_len)] = best_metric
visited: dict[tuple[str, int], float] = {}
Expand All @@ -369,8 +370,8 @@ def _dijkstra_single_source(
results: dict[str, tuple[PathNode, EdgeMetadata]] = {}

while pq:
current_metric, hub_id, path_node, acc_metrics = heapq.heappop(pq)

current_metric, _, path_node, acc_metrics = heapq.heappop(pq)
hub_id = path_node.hub_id
path_len = path_node.length if path_node is not None else 0
state = (hub_id, path_len)

Expand Down Expand Up @@ -436,7 +437,7 @@ def _dijkstra_single_source(

heapq.heappush(
pq,
(new_metric, next_hub_id, new_path_node, new_acc_metrics),
(new_metric, next(counter), new_path_node, new_acc_metrics),
)

return results
Expand Down