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