MCPcopy Create free account
hub / github.com/GraphiteEditor/Graphite / generate_stable_node_ids

Method generate_stable_node_ids

node-graph/graph-craft/src/proto.rs:250–261  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 2

compileMethod · 0.80

Calls 5

stable_node_idMethod · 0.80
replace_node_idMethod · 0.80
NodeIdClass · 0.50
lenMethod · 0.45

Tested by 1