mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Sort indexes during graph edge removal (#4649)
## Summary `remove_edge` will invalidate the last index in the graph, so we need to ensure that each index we look at is "earlier" than the last. Co-authored-by: bluss <bluss@users.noreply.github.com>
This commit is contained in:
parent
ea6185e082
commit
8d9b4a5e1c
1 changed files with 3 additions and 2 deletions
|
@ -360,11 +360,12 @@ fn propagate_markers(mut graph: IntermediatePetGraph) -> IntermediatePetGraph {
|
|||
// TODO(charlie): The above reasoning could be incorrect. Consider using a graph algorithm that
|
||||
// can handle weight propagation with cycles.
|
||||
let edges = {
|
||||
let fas = greedy_feedback_arc_set(&graph)
|
||||
let mut fas = greedy_feedback_arc_set(&graph)
|
||||
.map(|edge| edge.id())
|
||||
.collect::<Vec<_>>();
|
||||
fas.sort_unstable();
|
||||
let mut edges = Vec::with_capacity(fas.len());
|
||||
for edge_id in fas {
|
||||
for edge_id in fas.into_iter().rev() {
|
||||
edges.push(graph.edge_endpoints(edge_id).unwrap());
|
||||
graph.remove_edge(edge_id);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue