Graph manipulation for finding degree by search