MTH118
-
Upload
carlos-wolf -
Category
Documents
-
view
34 -
download
0
description
Transcript of MTH118
MTH118
Sanchita Mal-Sarkar
Routing Problems
The fundamental questions:
• Is there any proper route for the particular problem?
• If there are many possible routes, which one is the best (cost, distance, or time)?
Routing Problems
Examples:
• Mail delivery
• Garbage collection
• Newspaper delivery
• Internet access
Graphs
• Graph is a picture consisting of – Dots (called vertices)– Lines (called edges)
• Edges do not have to be straight lines
• Edges have to connect two vertices
• When an edge connects a vertex back with itself, then it is called a loop.
Examples of graphs
A B
C D
A
B
C
D Graph 1
Graph 2
Graph represents a relationship
Ron John
Bob Ruben
Edge represents “brother of ”
Adjacent vertices/edgesTwo vertices are adjacent if there is an edge joining them.Two edges are adjacent if they share a common vertex.
Vertices A and C are adjacent verticesAD and AC are adjacent edges
Degree of a vertex
deg(A) = 2, deg(B) = 1, deg(C) = 5, deg(D) = 5, deg(E) = 3
Paths
Vertex can appear on the path more than one.Edge cannot appear on the path more than once
A sequence of vertices so that each vertex in the sequence is adjacent to the next one
E, D, C, A. => A path from vertex E to vertex AE, D, C, D, A => Not a path because the edge DC
appears twice
CircuitsA path that starts and ends at the same vertex.
A, C, D, A => A circuit of length 3
Connected graphA graph is connected if it is possible to travel from any vertex to any other vertex along consecutive edges of the graphDisconnected => If it is not connected
Graph1, Graph4 => Connected Graph 2, Graph 3 => Disconnected
BridgeAbsence of the bridge (edge) will disconnect the graph
BD is a bridge
Euler PathsA path that travels through every edge of a graph.Edges can be traveled once since it is a pathTravel every edge 1) without lifting your pencil
2) without retracing any edge
R
A
L
D
No Euler paths
R
A
L
D
Several Euler pathsL,A, R, D, A, R, D, L, A
Euler circuitsA circuit that travels through every edge of a graphSame requirement as for an Euler path, as well asAdditional requirement: starting and ending vertex be the same.
A
B
C
D
E
F
Graph has Euler circuit
Euler Theorem 1• If a graph has many odd vertices, then it cannot have an
Euler circuit• If a graph is connected and every vertex is an even
vertex, then it has at least one Euler circuit (and usually more
A
B
C D
EGraph has no Euler circuit
Euler’s Theorem 2
• If a graph has more than two odd vertices, then it cannot have an Euler path.
• If a graph is connected and has exactly two odd vertices, then it has at least one Euler path (and usually more). Any such path must start at one of the odd vertices and end at the other one.
Euler Theorem 2
No Euler circuitBut, Euler path
No Euler circuitNo Euler path
Euler circuitEuler path
Euler’s Theorem 2
Euler circuitEuler path
No Euler circuitNo Euler path
No Euler circuitNo Euler path
No Euler circuitBut, Euler path
Euler’s Theorem 3• The sum of the degrees of all the vertices of a
graph equals twice the number of edges • A graph always has an even number of odd
vertices• A graph has seven vertices–two vertices of
degree 6, four vertices of degree 5, and one vertex of degree 2. The number of edges in the graph is 17.
• 2n = sum of the degree of all the vertices of a graph, n = no. of edges in the graph