Allow transforming graph before commands

This commit is contained in:
Joscha 2024-12-31 15:30:11 +01:00
parent ab7b7295ca
commit c573f1b0b0
8 changed files with 134 additions and 17 deletions

View file

@ -192,6 +192,22 @@ impl Data {
Self::read(&mut file)
}
pub fn check_consistency(&self) {
assert_eq!(
self.pages.len(),
self.graph.nodes.len(),
"inconsistent number of pages"
);
assert_eq!(
self.links.len(),
self.graph.edges.len(),
"inconsistent number of links"
);
self.graph.check_consistency();
}
pub fn redirect_target(&self, node: NodeIdx) -> Option<NodeIdx> {
if !self.pages[node.usize()].redirect {
return None;