Fixed assigning lowest cost of an edge