fn solve_nodepath(node: HexNode) -> HexGraph {
	// We assume that the HexNode has both chains down to size 0
	debug_assert!(node.is_solved());

	let HexNode { block, mut left, mut right } = node;

	if block.is_atom() {
		return HexGraph::leaf_block(block).unwrap();
	}

	debug_assert!(!left.is_empty());
	debug_assert!(!right.is_empty());
	let start = left.remove(0);
	let end = right.remove(0);

	debug_assert!(start.size == end.size);

	// Solve n-1 path
	let path = find_hexagon_path(block.clone(), start, end).to_vec();

	// Solve n-1 links
	let child_nodes = solve_links(path, left, right);

	// Recursively solve n-1 nodepaths
	let child_graphs = child_nodes.into_iter()
		.map(solve_nodepath)
		.collect::<ArrayVec<_>>()
		.into_inner()
		.ok().unwrap();

	HexGraph {
		block,
		children: Some(Box::new(child_graphs)),
	}
}
/// Given a HexNode, recursively solve it into a HexGraph
Given a HexNode, recursively solve it into a HexGraph
Given a HexNode recursively solve it into a HexGraph
fn solve_nodepath(node: HexNode) -> HexGraph {
	// We assume that the HexNode has both chains down to size 0
	debug_assert!(node.is_solved());
	let HexNode { block, mut left, mut right } = node;
	if block.is_atom() {
		return HexGraph::leaf_block(block).unwrap();
	}
	debug_assert!(!left.is_empty());
	debug_assert!(!right.is_empty());
	let start = left.remove(0);
	let end = right.remove(0);
	debug_assert!(start.size == end.size);
	// Solve n-1 path
	let path = find_hexagon_path(block.clone(), start, end).to_vec();
	// Solve n-1 links
	let child_nodes = solve_links(path, left, right);
	// Recursively solve n-1 nodepaths
	let child_graphs = child_nodes.into_iter()
		.map(solve_nodepath)
		.collect::<ArrayVec<_>>()
		.into_inner()
		.ok().unwrap();
	HexGraph {
		block,
		children: Some(Box::new(child_graphs)),
	}
}
fn solve_nodepath ( node : HexNode ) -> HexGraph { // We assume that the HexNode has both chains down to size 0 debug_assert ! ( node is_solved ( ) ) ; let HexNode { block , mut left , mut right } = node ; if block . is_atom ( ) { return HexGraph :: leaf_block ( block ) . unwrap ( ) ; } debug_assert ! ( left is_empty ( ) ) ; debug_assert ! ( right is_empty ( ) ) ; let start = left . remove ( 0 ) ; let end = right . remove ( 0 ) ; debug_assert ! ( start size end size ) ; // Solve n-1 path let path = find_hexagon_path ( block . clone ( ) , start , end ) . to_vec ( ) ; // Solve n-1 links let child_nodes = solve_links ( path , left , right ) ; // Recursively solve n-1 nodepaths let child_graphs = child_nodes . into_iter ( ) . map ( solve_nodepath ) . collect :: < ArrayVec < _ > > ( ) . into_inner ( ) . ok ( ) . unwrap ( ) ; HexGraph { block , children : Some ( Box :: new ( child_graphs ) ) , } }
Given a HexNode, recursively solve it into a HexGraph
Given a HexNode recursively solve it into a HexGraph
node
HexNode
node
HexNode