Checked for acceptable nodes in getCost and moved the return statement in addEdge