Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

CS (Graph Theory) vs.

AI
Graph theory also looks at explicit graphs

CMPUT 652: Lecture 2


Nathan Sturtevant

|V| vertices |E| edges (At most O(|V|2) edges) AI often uses implicit graphs Duplicate nodes hard to detect AI often assumes a constant branching factor

CS (Graph Theory) vs. AI


CS considers time polynomial in (nodes + edges) efcient AI (usually) considers this too expensive representation of implicit states takes log(nodes+edges)

CS (Graph Theory) vs. AI


CS is willing to have everything stored in memory polynomial in (nodes+edges) AI considers this exponential memory

CS (Graph Theory) vs. AI


But Pathnding is a special case Motivated by computer games Graph ts in memory Need extremely fast pathnding Willing to give up optimality

Overview
Problem Denition Assumptions Algorithms: BFS DFS DFID

Overview
Metrics Complete Solution Quality Time Complexity Space Complexity Assumption Uniform edges costs Brute-force search

BFS
Implementation Expand nodes and put them in a (FIFO) queue Pull rst node off of queue and expand it Goal test? Solution quality - complete? Finds optimal solution assuming uniform cost edges Proof?

BFS - Time Complexity


N (b, d) = 1 + b + b2 + . . . + bd1 + bd b N (b, d) = b + b2 + . . . + bd1 + bd + bd+1 b N (b, d) N (b, d) = bd+1 1 N (b, d) (b 1) = bd+1 1 bd+1 1 N (b, d) = b1 N (b, d) b bd+1 = bd b1 b1

BFS - Space Complexity


Same as # nodes expanded O(bd) Suppose: 1 byte per node 100 instructions / node generation 3Ghz machine 30 million nodes (bytes) per second 1 minute to ll 2GB of memory

DFS
Expand nodes and put them on a stack Pop top node and expand depth-rst expansion v. generation Solution quality -- delay discussion

DFS - Space Complexity


Assume we know the solution is at depth d How much memory required? O(d) v. O(bd)

Implementation Complexity
What do you keep in memory for BFS? Have to keep copy of each state What do you keep in memory for DFS? Only have to keep a single copy of the state Apply & undo moves to state

DFS - Time Complexity


Worst-case O(bd) Best-case O(d) Assumptions Duplicate detection? Innite graph? What if we dont know the solution depth? (Complete?)

DFID
Run DFS with successive depth bounds: 1, 2, 3d Solution Quality? Space Complexity?

DFID
Time complexity? BFS work at depth d: bdb/(b-1)
bd b b b b b + bd1 + bd2 + ... + b + b1 b1 b1 b1 b1 b (bd + bd1 + bd2 + . . . + b + 1) b1 b 2 b d b b = bd ( ) b1 b1 b1

You might also like