Move code to generate graph into a BT