Work in progress: No visualisation. Context displayed as JSON.

See binary search or quicksort for complete examples. Stay tuned for updates.

graph = {"you":["alice","bob","claire"],"bob":["anuj","peggy"],"alice":["peggy"],"claire":["thom","jonny"],"anuj":[],"peggy":[],"thom":[],"jonny":[]}
name = "you"
0. function bfs(graph, name) {
1. const queue = [...graph[name]];
2. const searched = new Set();
3.
4. while (queue.length > 0) {
5. const person = queue.shift();
6.
7. if (!searched.has(person)) {
8. if (isSeller(person)) {
9. return person;
10. }
11.
12. queue.push(...graph[person]);
13. searched.add(person);
14. }
15. }
16.
17. return false;
18. }