As we noted in the previous tutorial post our Graph class is very good at returning all possible paths, but cannot tell if one path is better than another.
In the case of the graph shown the possible routes from S to G would be either SAG or SABG. If we assume that the path finding is for an enemy tank and that the tank travels at a constant speed then SAG is faster than SABG.
However this may not always be the case. Say that the edge between nodes A and G intersects a swamp which slows the speed of by 70%. This would mean that route SABG is faster.
Luckily implementing a system to a system to take this in to account is not too difficult.
Note the diagram shows a number next to each edge. This is the edge cost which summarises how complex a given edge would be as part of any given path. How you define these values is up to you, it could be affected by the land conditions, incline, etc… but they should ultimately represent the amount of time it takes to travel along that given edge.
Knowing this we can say that the possible paths now have a cost. Path SAG has a cost of 11 where path SABG has a cost of 8. This would mean that path SABG is the more efficient route as the cost of path SAG is greater.


