0

I am just wondering if anyone can help me understand some of the notation involved in this pseudocode/ocaml notation algorithm for Uniform Cost Search.

This is the algorithm we were given:

Input: Graph G = (V, E), Start state s, Set of goal states F
Output: Path P ⊆ E
1 begin
2 let Frontier = {s};
3 let Explored = {s};
4 while Frontier != [] do
5 let v ∈ Frontier, such that Path(s,v) has lowest cost;
6 let Frontier = Frontier\{v};
7 if v ∈ F then
8 return Path(s,v)
9 end
10 else
11 let Explored = {v}∪ Explored;
12 let Frontier = Frontier∪{v-subscript(1), . . . , v-subscript(n)},
where (v, v-subscript(i)) ∈ E and v-subscript(i) !∈ Explored.
13 end
14 end
15 return failure;
16 end

I am confused about lines 6,11 and 12. Could someone explain these lines to me? And I just want to make sure I'm right in thinking the symbol ∈ means "member of"? And finally what does the symbol ⊆ represent? Used in path output line. Thanks in advance to anyone that can help! :-)

toastedDeli
  • 570
  • 5
  • 28
  • 1
    It seems your questions are simply about [basic set theory notation](https://en.wikipedia.org/wiki/Set_theory#Basic_concepts_and_notation) – Daniel Bünzli Oct 18 '15 at 15:49
  • Curious, what source calls this ocaml notation? ∈ does mean member of, line 6 means replace `Frontier` with `Frontier` "without" `v`, and line 11 means replace `Explored` with `Explored` with `v` added (the symbol there stands for set union). Line 12 has another set union. – antron Oct 18 '15 at 15:51

1 Answers1

0

Here's my take:

6 let Frontier = Frontier \ {v}

It says to remove v from Frontier. \ is a set subtraction.

11 let Explored = {v} ∪ Explored

It says to add v to Explored. is the standard union operator.

12 let Frontier = Frontier∪{v-subscript(1), . . . , v-subscript(n)},
    where (v, v-subscript(i)) ∈ E and v-subscript(i) !∈ Explored

It says to add to Frontier all the nodes adjacent to v that aren't already explored (already in Explored).

(@DanielBünzli is right, these are standard notations.)

Jeffrey Scofield
  • 65,646
  • 2
  • 72
  • 108