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],
)
| 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() { |