Only place real "Ultimate Goal" elements at the bottom of the graph
All checks were successful
/ build (push) Successful in 1m12s

"Ultimate Goal" elements are only counted as such if they fulfil the
following requirements:

- They have the "Ultimate Goal" issue label
- They are not depended on by any other elements
This commit is contained in:
Rahix 2026-01-23 14:55:54 +01:00
parent 8b0aef0599
commit 81ce471d0e

View file

@ -199,12 +199,23 @@ impl Tree {
} }
pub fn iter_ultimate_elements<'a>(&'a self) -> impl Iterator<Item = ElementIndex> + 'a { pub fn iter_ultimate_elements<'a>(&'a self) -> impl Iterator<Item = ElementIndex> + 'a {
self.graph.node_indices().filter(|index| {
// If there are no incoming edges, then this is an ultimate element!
self.graph self.graph
.node_indices()
.filter(|index| {
self.graph.node_weight(*index).unwrap().status == ElementStatus::UltimateGoal
})
.filter(|index| {
// Ultimate goal elements must not have any incoming dependency edges. Warn and
// ignore it, if one does.
let has_no_incoming = self.graph
.neighbors_directed(*index, petgraph::Direction::Incoming) .neighbors_directed(*index, petgraph::Direction::Incoming)
.next() .next()
.is_none() .is_none();
if !has_no_incoming {
let el = self.graph.node_weight(*index).unwrap();
log::warn!("Element #{} is marked \"Ultimate Goal\" but is depended on by others? Ignoring...", el.issue_number);
}
has_no_incoming
}) })
} }