Code for edge expansion.