MCPcopy Create free account
hub / github.com/hashintel/hash / push_start_node

Method push_start_node

libs/@local/hashql/core/src/graph/algorithms/mod.rs:154–161  ·  view source on GitHub ↗

Adds a starting node to the traversal. If the node has already been visited, this has no effect. This allows traversing disconnected components by adding multiple starting nodes. # Examples ```rust # use hashql_core::graph::{LinkedGraph, algorithms::DepthFirstTraversal}; # let mut graph = LinkedGraph::new(); let n1 = graph.add_node("A"); let n2 = graph.add_node("B"); let n3 = graph.add_node("C"

(&mut self, start_node: N)

Source from the content-addressed store, hash-verified

152 /// # assert_eq!(visited, [n3, n1, n2]);
153 /// ```
154 pub fn push_start_node(&mut self, start_node: N)
155 where
156 G: DirectedGraph<NodeId = N>,
157 {
158 if self.visited.insert(start_node) {
159 self.stack.push(start_node);
160 }
161 }
162
163 /// Returns whether the given node has been visited.
164 ///

Callers 4

depth_first_traversalMethod · 0.80
with_start_nodeMethod · 0.80

Calls 4

push_backMethod · 0.80
pushMethod · 0.65
insertMethod · 0.45
successorsMethod · 0.45

Tested by

no test coverage detected