MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / build_graph

Function build_graph

atomic-core/src/output/repo/fork.rs:194–218  ·  view source on GitHub ↗

Build a graph where the vertex at `parent_idx` has the given child vertex indices. Vertices are pushed in order 0..N where 0 is DUMMY.

(
        vertices: &[GraphNode<NodeId>],
        parent_idx: usize,
        child_indices: &[usize],
    )

Source from the content-addressed store, hash-verified

192 /// Build a graph where the vertex at `parent_idx` has the given child
193 /// vertex indices. Vertices are pushed in order 0..N where 0 is DUMMY.
194 fn build_graph(
195 vertices: &[GraphNode<NodeId>],
196 parent_idx: usize,
197 child_indices: &[usize],
198 ) -> AliveGraph {
199 let edge = SerializedGraphEdge::new(EdgeFlags::BLOCK, Position::ROOT, NodeId::ROOT);
200
201 let mut graph = AliveGraph::new();
202
203 for (i, v) in vertices.iter().enumerate() {
204 if i == 0 {
205 graph.push_vertex(AliveVertex::DUMMY);
206 } else {
207 graph.push_vertex(AliveVertex::new(*v));
208 }
209
210 if i == parent_idx {
211 graph.set_last_children_start();
212 for &ci in child_indices {
213 graph.push_child_to_last(Some(edge), VertexId::new(ci));
214 }
215 }
216 }
217 graph
218 }
219
220 #[test]
221 fn no_fork_single_child() {

Callers 5

no_fork_single_childFunction · 0.85
three_way_forkFunction · 0.85

Calls 4

push_vertexMethod · 0.80
push_child_to_lastMethod · 0.80
iterMethod · 0.45

Tested by 5

no_fork_single_childFunction · 0.68
three_way_forkFunction · 0.68