Rewrote algorithm to successfully run on  more graph types