Presentation is loading. Please wait.

Presentation is loading. Please wait.

Source: CSE 214 – Computer Science II Graphs.

Similar presentations


Presentation on theme: "Source: CSE 214 – Computer Science II Graphs."— Presentation transcript:

1 Source: http://orange.math.buffalo.edu/241/graph_paper.gifhttp://orange.math.buffalo.edu/241/graph_paper.gif CSE 214 – Computer Science II Graphs

2 What kind of data structure is the Internet? Ref: http://personalpages.manchester.ac.uk/staff/m.dodge/cybergeography/atlas/historical.htmlhttp://personalpages.manchester.ac.uk/staff/m.dodge/cybergeography/atlas/historical.html

3 What kind of data structure is used by game AI for pathfinding?

4 You guessed it, Graphs! What is a graph? –a non-linear data structure –consists of nodes & links between nodes –nodes can be linked in any pattern, not necessarily hierarchical –nodes can be directed, or undirected –can be weighted

5 This is a tree D A B GF C E

6 This is a graph D A B GF C E

7 And this is a graph D A B GF C E

8 D A B GF C E

9 D A B GF C E

10 Undirected Graphs A set of nodes –vertices And a set of links between the nodes –edges Each edge connects two vertices Graph walkers (like travelers) may move across undirected edges in both directions

11 An undirected graph D A B G F C E

12 Directed Graphs A set of nodes –vertices And a set of links between the nodes –edges Each edge is associated with 2 vertices: –a source vertex –a target vertex Graph walkers (like travelers) may move across directed edges only from source to target

13 A directed graph D A B G F C E

14 A weighted graph Can be an undirected or direct graph Each edge is weighted with some value –represents cost of edge Cost of what? –depends on application Might be: –distance, resistance, money. Etc.

15 A weighted graph D A B G F C E 5 6 8 11 3 9 7 12 4 5

16 How can we define a graph? Many options –nodes (we’ve seen this already, similar to trees) –an adjacency matrix –edge sets

17 Adjacency Matrix A 2D table –2D array –row for each node –column for each node Values in cells can be –boolean denoting are they connected OR –numeric representing weighting of connections

18 Adjacency Matrix ABCD A0560 B5093 C6907 D0370 A B D C 5 6 3 9 7

19 Edge sets List all the edges in a graph Advantage: –more efficient data management For what? –Graph walking –Graph manipulation Ex, 3D meshes: –vertex buffers & index buffers –render mesh needs graph traversal

20 3D Models/Meshes are textured graphs Ref: http://www.cubixstudio.com/HTML/Product/MaleContentPackMoreInfo.htmhttp://www.cubixstudio.com/HTML/Product/MaleContentPackMoreInfo.htm

21 Walking graphs Many problems: –Shortest path problems –Traveling salesman problems –Chinese postman problems –Etc. Many algorithms for calculating solutions: –Greedy, Djikstra’s algorithm, A*, etc.

22 Want to learn more? AMS 301: Finite Mathematical Structures CSE 352: Artificial Intelligence CSE 373: Analysis of Algorithms CSE 380: Computer Game Programming CSE 381: Advanced Game Programming


Download ppt "Source: CSE 214 – Computer Science II Graphs."

Similar presentations


Ads by Google