function path = shortest_path(G, s, P)
% SHORTEST_PATH Find the shortest path in an unweighted undirected graph to a node that satisfies P
% path = shortest_path(G, s, P)
% If there is no node that satisfies P, path = -1.

[d, pred, target] = bfs(G, s, 0, P);
path = [];
if target == -1
  path = -1;
  return;
end
source = s;
while target ~= source
  path = [target path];
  target = pred(target);
end

