Fixing bug where breadth-first search was not returning desired result when root and destination are the same

This commit is contained in:
Chris Cameron
2017-12-12 16:54:53 -05:00
parent 6db084853e
commit 025400bf7e
2 changed files with 16 additions and 0 deletions

View File

@@ -69,6 +69,10 @@ namespace ICD.Common.Utils
if (comparer == null)
throw new ArgumentNullException("comparer");
// Edge case - root and destination are the same
if (comparer.Equals(root, destination))
return new[] {root};
Queue<T> queue = new Queue<T>();
queue.Enqueue(root);