Skip to content

Commit 558385b

Browse files
committed
Merge remote-tracking branch 'origin/main' into scene
2 parents c11268f + a6a0dec commit 558385b

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
* Changed `SceneObject.frame` to read-only result of `Frame.from_transformation(SceneObject.worldtransformation)`, representing the local coordinate system of the scene object in world coordinates.
1717
* Changed `SceneObject.worldtransformation` to the multiplication of all transformations from the scene object to the root of the scene tree, there will no longer be an additional transformation in relation to the object's frame.
18+
* Fixed call to `astar_shortest_path` in `Graph.shortest_path`.
19+
20+
### Removed
1821

1922

2023
## [2.10.0] 2025-03-03

src/compas/datastructures/graph/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ def shortest_path(self, u, v):
12041204
:meth:`compas.topology.astar_shortest_path`
12051205
12061206
"""
1207-
return astar_shortest_path(self.adjacency, u, v)
1207+
return astar_shortest_path(self, u, v)
12081208

12091209
# --------------------------------------------------------------------------
12101210
# Default attributes

tests/compas/datastructures/test_graph.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,38 @@ def test_graph_data2():
117117
assert Graph.validate_data(other.__data__)
118118

119119

120+
def test_shortest_path():
121+
graph = Graph()
122+
graph.add_edge(1, 2)
123+
graph.add_edge(2, 3)
124+
graph.add_edge(3, 4)
125+
graph.add_edge(5, 6)
126+
127+
# Test shortest path from node 1 to node 4
128+
path = graph.shortest_path(1, 4)
129+
assert path == [1, 2, 3, 4]
130+
131+
# Test shortest path from node 1 to node 3
132+
path = graph.shortest_path(1, 3)
133+
assert path == [1, 2, 3]
134+
135+
# Test shortest path from node 2 to node 4
136+
path = graph.shortest_path(2, 4)
137+
assert path == [2, 3, 4]
138+
139+
# Test shortest path from node 4 to node 1
140+
path = graph.shortest_path(4, 1)
141+
assert path == [4, 3, 2, 1]
142+
143+
# Test shortest path from node 5 to node 6
144+
path = graph.shortest_path(5, 6)
145+
assert path == [5, 6]
146+
147+
# Test shortest path from node 3 to node 5 (should be None)
148+
path = graph.shortest_path(3, 5)
149+
assert path is None
150+
151+
120152
# ==============================================================================
121153
# Properties
122154
# ==============================================================================

0 commit comments

Comments
 (0)