/*
test graph: [[1,2,3,4,5,6,7],[[1,2],[2,3],[3,4],[1,4],[1,5],[1,6],[4,3],[4,5]]]
Graph representation
1
2 4 5 6
3
4
3 5
So the graph is encoded as a list [V,E]:
* where V is a list of nodes
* and E is a list of directed edges [U,V]
Tasks:
1. Auxiliaries
- Write a predicate which extracts the first element of a list (will use on list of edges)
- Write one which extracts the last element of a list (will use on list of edges)
- Write a predicate which removes all occurrences of an element from a list
(if already did last time, can use predefined delete/3 from prolog).
2. Explorations
- Write a predicate which builds the adjacency list of a node from a graph represented as above
you will find "findall/3" a useful predicate in prolog ; How it works:
- Write a predicate which constructs the BFS traversal of a graph
3. Make it more generic
- Write a predicate which constructs the traversal of a graph, where the strategy is given as input (explain call), reuse all above
*/
%TODO
%do_bfs(+Start, +Graph, -Result).
% Start - the node where to start the bfs from
% Graph - a list like [V, E] just like above.
% Result - the result of the explored nodes you pass through (ordered by first discovered)
do_bfs(Start, Graph, R) :- fail.