170 likes | 420 Vues
A. B. C. D. E. F. G. Topics. Paths and Circuits (11.2). e 2. e 1. e n. …. v 1. A. v. F. G. C. D. E. w. B. Definitions (p.667). Let G be a graph, and v and w be vertices of G. A walk from v to w has the form v e 1 v 1 e 2 v 2 ...e n-1 v n-1 e n w
E N D
A B C D E F G Topics • Paths and Circuits (11.2)
e2 e1 en … v1 A v F G C D E w B Definitions (p.667) • Let G be a graph, and v and w be vertices of G. • A walk from v to w has the form ve1v1e2v2...en-1vn-1enw where v0 (the starting point) is v and vn (the destination) is w. Note: Each vi and ei may be repeated. Exercise: Find example walks from A to G in the graph. Q: Is there a best walk? Shortest walk?
Why are we concerned with walks in a graph? • Many real-world applications … • Navigation • Transportation • Computer networks Network topology Routing of data packets Wireless network (node movement) … • Problem solving, games, gambling, … • Searching (e.g., searching the Internet) • Communication • Management • …
Why are we concerned with walks in a graph? See http://en.wikipedia.org/wiki/Graph_theory#Applications • “Applications of graph theory are primarily, but not exclusively, concerned with labeled graphs and various specializations of these. • Structures that can be represented as graphs are ubiquitous, and many problems of practical interest can be represented by graphs. • The link structure of a website could be represented by a directed graph: the vertices are the web pages available at the website and a directed edge from page A to page B exists if and only if A contains a link to B. • A similar approach can be taken to problems in travel, biology, computer chip design, and many other fields. • The development of algorithms to handle graphs is therefore of major interest in computer science.”
A B C D E F G Why are we concerned with walks in a graph? • A walk may represent a solution in the problem domain. • Example: In a sociogram, a walk represents one of the communication paths between two persons in an organization or community. • With some specialization, concepts such as ‘channels of influence’, ‘most effective communication path’, ‘cliques’, etc. start to make sense.
A B C D E F G Connectedness p.669: Let G be a graph. • Two vertices v and w of G are connected iff there exist a walk from v to w. • The graph G is connected iff given any two vertices v and w in G, there exist a walk from v to w. p.670: A graph H is a connected component of a graph G iff • H is a subgraph of G, • H is connected, and • No connected subgraph of G has H as a subgraph and contains vertices or edges that are not in H. Example 11.2.4 Exercise: Find all the connected components in the example graph.
A C B D E Paths • Let G be a graph, and v and w be vertices of G. • A path from v to w is a walk from v to w with no repeated edges. Note:Repeated vertices are allowed. Exercise: Find example paths from A to E in the graph. Q1: How many paths are there? Q2: What is the shortest path?
A C B D E Simple Paths • Let G be a graph, and v and w be vertices of G. • A simple path from v to w is a path from v to w with no repeated vertices. Note:Neither repeated edges nor repeated vertices are allowed. Exercise: Find example simple paths from A to E in the graph. Q1: How many simple paths are there? Q2: What is the shortest simple path?
A C B D E Closed Walks • Let G be a graph, and v and w be vertices of G. • A closed walkis a walk that starts and ends at the same vertex. Note:Repeated edges and vertices are allowed. Exercise: Find example closed walks in the graph. Q1: How many closed walks are there? Does this question make sense at all? Q2: Starting with node A, how many closed walks are there?
A C B D E Circuits • Let G be a graph, and v and w be vertices of G. • A circuitis a closed walkwith no repeated edges. Note:Repeated vertices are allowed. Exercise: Find example circuits in the graph. Q1: Starting with node A, how many circuits are there?
A C B D E A B C D E F Simple Circuits • Let G be a graph, and v and w be vertices of G. • A simple circuitis a circuitwith no repeated vertices. Note:Neither repeated edges nor repeated vertices are allowed. Exercise: Find example simple circuits in the graph. Q1: Starting with node A, how many simple circuits are there?
A B C D E F Comparisons • p.667: Table of comparisons • Q: What’s the difference between a walk and a path? • How about a walk and a closed walk? • How about a path and a circuit? • How about a path and a simple path? • How about a circuit and a simple circuit? • How about a simple path and a simple circuit?
A C B D E A C B D E Euler Paths • p.675: Let G be a graph. An Euler path for G is a path that visits each edge exactly once. Note:Repeated vertices are allowed. • Exercise: Find an Euler path from A to D in the example graphs. Q: Does every graph have an Euler path? Nope! • Theorem: In an Euler path, either all or all but two vertices (i.e., the two endpoints) have an even degree.
A C B D E Finding an Euler Path • Example 11.2.7 Correction: Remove the edge between node I and K in the graph on page 676. Q: Find other Euler paths in the example graph. Q: How many Euler paths are there? Q: Is there an algorithm to find all the Euler paths in a given graph? Exercise: Find all the Euler paths from A to D in this example graph.
A C B D E A C B D E Euler Circuits • p.671: Let G be a graph. An Euler circuit for G is a circuit that contains every vertex and every edge of G. Note: Although a vertex may be repeated, an edge may not be repeated in an Euler circuit. Exercise: Find an Euler circuit starting with A in the example graphs. Theorem 11.2.2 (p.671): If a graph G has an Euler circuit, then every vertex of G has even degree. Theorem 11.2.3 (p.672): If every vertex of a nonemptyconnected graph G has even degree, then G has an Euler circuit.