Fixed a bug that caused exceptions when finding a path in a network which is not fully connected.