Download presentation
Presentation is loading. Please wait.
1
CSC 172 DATA STRUCTURES
2
WORKSHOP LEADER INTEREST MEETING FRIDAY, APRIL 6th 12:30pm 601 CSB
Good grades in CSC171 & CSC172 Good people skills Favorable approach to workshops
3
GRAPHS GRAPH G= (V,E) V: a set of vertices (nodes)
E: a set of edges connecting vertices V An edge is a pair of nodes Example: V = {a,b,c,d,e,f,g} E = {(a,b),(a,c),(a,d),(b,e),(c,d) ,(c,e),(d,e),(e,f)} a b d c e f g
4
PATHS ON GRAPHS Simple Euler Hamiltonian
5
SIMPLE PATH Given two vertices is there a simple path that connects them?
6
HAMILTONIAN PATH Given a starting vertex is there a path through the graph that visits each (and every) vertex exactly once? If the path finishes at the starting vertex, it is a Hamiltonian cycle (a.k.a. The Traveling Salesman Problem).
7
EULER PATH Given a starting vertex is there a path through the graph that traverses each (and every) edge exactly once?
8
SIMPLE PATH Given two vertices is there a simple path that connects them? We can find this path in linear O(V + e) time Sort of, recall that e is O(V2) Use Depth first search. How can we modify DFS to print the path?
9
HAMILTONIAN PATH Given a starting vertex is there a path/cycle/tour through the graph that visits each (and every) vertex exactly once? In order to do this, we may need to consider every possible path. (How many are there?) We may need to consider (V-1)! paths in a complete graph.
10
EULER PATH Given a starting vertex is there a path through the graph that traverses each (and every) edge exactly once? We can prove that an Euler cycle exists iff the graph is connected and all nodes have even degree. We can find the path in linear time.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.