From 73d09bfe9670d8e04e3b0892cb609e0552cdad94 Mon Sep 17 00:00:00 2001 From: hwelch-fle <91618355+hwelch-fle@users.noreply.github.com> Date: Fri, 12 Jun 2026 10:57:25 -0400 Subject: [PATCH 1/2] Fix scaling; defer to rustworx function --- src/pygraph/pygraph.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pygraph/pygraph.py b/src/pygraph/pygraph.py index 5306769..fe0d095 100644 --- a/src/pygraph/pygraph.py +++ b/src/pygraph/pygraph.py @@ -336,7 +336,6 @@ def adj_list(self, node: Node | NodeId) -> dict[Node, Edge]: def spring_solve( self, - scale_factor: int = 1000, pos: dict[int, tuple[float, float]] | None = None, fixed: set[int] | None = None, k: float | None = None, @@ -354,7 +353,6 @@ def spring_solve( speed up rendering time for complex graphs. Args: - scale_factor: Scale the position (`0->1`) with this factor (default: `1000`) *args: [See Here](https://www.rustworkx.org/apiref/rustworkx.digraph_spring_layout.html) """ @@ -365,8 +363,8 @@ def spring_solve( for node_id in self.node_map.values(): x, y = layout[node_id] node = self.graph[node_id] - node['x'] = int(x * scale_factor) - node['y'] = int(y * scale_factor) + node['x'] = int(x) + node['y'] = int(y) # Dunder Overrides From 79a009ebd659a5c027b82af798176d467e6e9bc8 Mon Sep 17 00:00:00 2001 From: hwelch-fle <91618355+hwelch-fle@users.noreply.github.com> Date: Fri, 12 Jun 2026 10:57:55 -0400 Subject: [PATCH 2/2] Fix shortest_path; return empty list if no path instead of raising --- src/pygraph/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pygraph/utils.py b/src/pygraph/utils.py index 7774d2a..a635a49 100644 --- a/src/pygraph/utils.py +++ b/src/pygraph/utils.py @@ -43,7 +43,10 @@ def shortest_paths(nx: Network, fr: Node | NodeId, to: Node | NodeId, *, directe shortest = rx.digraph_all_shortest_paths( nx.graph, fr, to, as_undirected=not directed ) - return [[nx[edge] for edge in itertools.pairwise(path)] for path in shortest] + try: + return [[nx.graph.get_edge_data(*edge) for edge in itertools.pairwise(path)] for path in shortest] + except rx.NoEdgeBetweenNodes: + return [] def style_edges(edges: Iterable[Edge], **options: Unpack[EdgeOptions]) -> list[Edge]: