Title: Review of Graphs and Trees
1Review of Graphs and Trees
- Graph
-
- Directed graph
-
- Cycle
-
2Review of Graphs and Trees
- Tree
- Subtree
- Branch
- Root
- Leaf Node
- Intermediate Node
- Ply
- Branching Factor
3Two General Views of Problem Representations
- State-Space Representation
- Problem-Reduction Representation
4State-Space Representation
(S, I, G, O, R)
- S - the set of states or snapshots
of the problem at various stages of
solution - I Ì S -
- G Ì S -
- O -
- R -
5- Search Space
- Search Graph
6Problem
Three sons and their father wish to cross a
river. The father weighs 200 lbs and each son
weighs 100 lbs. They have a boat that can only
carry 200 lbs (none can swim and the river has
alligators). Son 3 cannot row the boat, but
everyone else can. What are the steps required
for them to cross the river?
States Operators
7Finding a Solution
8What is the Search Space?
123F
F132
13F2
F123
F312
23F1
F213
F231
F123
1F23
12F3
F123
3F12
2F13
F123
F123
9What is a Solution Path?
123F
F132
13F2
F123
F312
23F1
F213
F231
F123
1F23
12F3
F123
3F12
2F13
F123
F123
10Problem Reduction Representation
(G, I, P, O, R)
- G - the set of goals or problem
descriptions - I ÃŽ G -
- P Ì G -
- O -
- R -
11Problem
- The Tower of Hanoi Puzzle
- There are four disks (A, B, C, D) of graduated
sizes initially stacked on Peg 1 of the three
pegs. A, the smallest, is on the top and D, the
largest, is at the bottom. The disks are to be
transferred to Peg 3 observing the following
rules - (1)
- (2)
Initial State
Final State
A B C D
A B C D
1
2
3
1
2
3
12- The only operator
- The only primitive problem
- Given three pegs i, j, and k, the problem of
moving a stack of size ngt1 from peg i to peg k
can be replaced by the three problems - 1.
- 2.
- 3.
-
13- One possible representation of a problem
description is - The only operator is then
- And the primitive problem is
14- The solution tree is then
15- In general, the search graph is called an AND/OR
Graph - Rules for And/Or Graphs
- 1. Each node represents either a single problem
or a set of problems - 2. The root node is the original problem
- 3. A leaf node is called a terminal node if it
represents a primitive problem and, therefore,
has no descendants - 4. When an operator is applied to a problem P
transforming it into a set of subproblems, A, B,
C, any of which will solve the original
problem, then these nodes are called OR nodes - 5. When an operator is applied to a problem P
transforming it into a set of subproblems, A, B,
C, all of which must be solved to solve the
original problem, then these nodes are called AND
nodes - 6. Typically, the graphs that are grown
alternate an OR ply with an AND ply, but if only
a single OR node exists, it may be omitted in the
constructed tree
16Sample And/Or Tree
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
When generating a solution, you only need to
expand as much of this tree (or graph) as is
needed to have a solution. This is known as the
solution tree (or graph).
17- Developing a solution to a problem involves
determining if the root node has a solution - For any node in the tree, the node has a solution
if
18- Developing a solution to a problem involves
determining if the root node has a solution - For any node in the tree, the node has no
solution if
19Given the following And/Or Tree
6
12
1
2
3
4
5
7
8
9
10
11
- What are possible combinations of leaf nodes
that will generate a solution to the original
problem?
20Given the following And/Or Tree
6
12
1
2
3
4
5
7
8
9
10
11
- What combinations of leaf nodes will cause the
original problem to not have a solution?
21NOTE!
- The state-space and problem-reduction
representations are equivalent and algorithms
exist for recasting a problem description from
one representation into the other - However, often one of these representations will
appear more natural for representing a particular
problem than the other
22Forward vs. Backward Reasoning
- If we think of our problem using the state-space
representation, what we want is a path through
the problem state from an initial state to a goal
state - Two approaches can be used
- Which method is better?
- Forward Reasoning --
- Backward Reasoning --
- 1.
- 2.
- 3.