Closed aberke closed 5 years ago
@aberke I will try to merge this before the v1.0 release however I just want to understand clearly what you did here:
so instead of calling
if (path.indexOf(toNode) == 0)
you replace it by
if (pathIndex == 0)
where pathIndex is computed only ones?
That's the only main difference I see. Do you think path.indexOf(toNode) iterate through all the graph?
Hi @agrignard, The answer is yes. The reason this is very helpful: ArrayList.indexOf is O(N) in complexity where N is the number of items in the array (i.e. nodes in the path). My use of updating the index is just O(1)
Without this change there is an O(N*M) operation for each call of update
With this change the operation is instead O(N) for each update