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

Function build_graph

atomic-core/src/output/repo/fork.rs:244–268  ·  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

242 /// Build a graph where the vertex at `parent_idx` has the given child
243 /// vertex indices. Vertices are pushed in order 0..N where 0 is DUMMY.
244 fn build_graph(
245 vertices: &[GraphNode<NodeId>],
246 parent_idx: usize,
247 child_indices: &[usize],
248 ) -> AliveGraph {
249 let edge = SerializedGraphEdge::new(EdgeFlags::BLOCK, Position::ROOT, NodeId::ROOT);
250
251 let mut graph = AliveGraph::new();
252
253 for (i, v) in vertices.iter().enumerate() {
254 if i == 0 {
255 graph.push_vertex(AliveVertex::DUMMY);
256 } else {
257 graph.push_vertex(AliveVertex::new(*v));
258 }
259
260 if i == parent_idx {
261 graph.set_last_children_start();
262 for &ci in child_indices {
263 graph.push_child_to_last(Some(edge), VertexId::new(ci));
264 }
265 }
266 }
267 graph
268 }
269
270 #[test]
271 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