Fixed issue with totalCost, actually caused by vertices not accepting self referential edges