Convert all node IDs to be stable (based on the hash generated by [`ProtoNode::stable_node_id`]). This function requires that the graph be topologically sorted.
(&mut self)
| 248 | /// Convert all node IDs to be stable (based on the hash generated by [`ProtoNode::stable_node_id`]). |
| 249 | /// This function requires that the graph be topologically sorted. |
| 250 | pub fn generate_stable_node_ids(&mut self) { |
| 251 | debug_assert!(self.is_topologically_sorted()); |
| 252 | let outwards_edges = self.collect_outwards_edges(); |
| 253 | |
| 254 | for index in 0..self.nodes.len() { |
| 255 | let Some(sni) = self.nodes[index].1.stable_node_id() else { |
| 256 | panic!("failed to generate stable node id for node {:#?}", self.nodes[index].1); |
| 257 | }; |
| 258 | self.replace_node_id(&outwards_edges, NodeId(index as u64), sni); |
| 259 | self.nodes[index].0 = sni; |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | // TODO: Remove |
| 264 | /// Create a hashmap with the list of nodes this proto network depends on/uses as inputs. |