120
Foundations of Discrete Mathematics Chapters 9 and 10 By Dr. Dalia M. Gil, Ph.D.

Foundations of Discrete Mathematics Chapters 9 and 10 By Dr. Dalia M. Gil, Ph.D

Embed Size (px)

Citation preview

  • Foundations of Discrete MathematicsChapters 9 and 10By Dr. Dalia M. Gil, Ph.D.

  • GraphsGraphs are discrete structures consisting of vertices and edges that connect these vertices.

  • GraphsA graph is a pair (V, E) of sets, V nonempty and each element of E a set of two distinct elements of V.The elements of V are called vertices; the elements of E are called edges.

  • GraphsIf e is an edge, then e = {v, w}, where v and w are different elements of set V called the end vertices of ends of e.The vertices v and w are said to be incident with the edge vw. The edge vw is incident with each vertex.

  • GraphsTwo vertices are adjacent if they are the end vertices of an edge.

    Two vertices are adjacent if they have a vertex in common.The number of edges incident with a vertex v is called the degree of that vertex and is denoted deg v.

  • GraphsIf deg v is an even number, then v is said to be an even vertex.

    If deg v is an odd number, then v is odd vertex.

    A vertex of degree 0 is said to be isolated.

  • SubgraphA graph G1 is a subgraph of another graph G if and only if the vertex and edge sets of G1 are, respectively, subsets of the vertex and edge sets of G.

  • Example: SubgraphA graph G and three subgraphs G1, G2, and G3Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 290

  • A Bipartite GraphA bipartite graph is one whose vertices can be partitioned into two (disjoint) sets V1 and V2, called bipartition sets in such a way that every edge joins a vertex in V1 and a vertex in V2.

  • A Bipartite GraphThe complete bipartite graph on bipartition sets of m vertices and n vertices, respectively, is denoted Km,n.

  • Bipartite GraphsThree bipartite graphs, two of which are not complete. No two top vertices are adjacent, and no two bottom vertices are adjacent.Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 291

  • EulerThe sum of the degrees of the vertices of a pseudograph is an even number equal to twice the number of edges.

    In symbols, if G(V, E) is a pseudograph, then

    deg v = 2 |E| vV

  • Example: EulerThe graph has 8 vertices of degree 3

    deg v = 8(3) = 24 =2|E| vV it must have 12 edges.Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 291

  • GraphsThere are several different types of graphs that differ with respect to the kind and number of edges that connect a pair of vertices.Many real problems can be solved using graph models.

  • Types of GraphsSimple graph.

    Multigraph.

    Pseudograph.

    Directed graph.

    Direct multigraph.

  • A Simple GraphA simple graph G = (V, E) consists of

    V, a nonempty set of vertices, and

    E, a set of unordered pairs of distinct elements of V (edges).

  • Example of a Simple GraphA computer network that represents computers (vertices) and telephone lines (undirected edges) that connect two distinct vertices.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 538

  • A MultigraphA multigraph G = (V, E) consists of a set V of vertices, a set E of edges, and a function f(from E to {{u, v} | u, v V, u v}). The edges e1 and e2 are called multiple or parallel edges if f(e1) = f(e2).

  • Example of a MultigraphThis graph consist of vertices and undirected edges between these vertices with multiple edges between pairs of vertices allowed (two or more edges may connect the same pair of vertices).Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 538

  • A PseudographA pseudograph G = (V, E) consists of a set V of vertices, a set E of edges, and a function f (from E to {{u, v} | u, v V}). An edge is a loop if f (e) = {u, v} = {u}

  • Example of a PseudographA computer network may contain vertices with loops, which are edges from a vertex to itself.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 539

  • A Direct GraphA direct graph (V, E) consists of

    a set of vertices V and

    a set of edges E that are ordered pairs of elements of V.

  • Example of a Direct GraphA network may not operate in both directions. In this case an arrow pointing from u to v to indicate the direction of the edge (u, v) is used.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 539

  • A Directed MultigraphA directed multigraph G = (V, E) consists of a set V of vertices, a set E of edges, and a function f (from E to {(u, v) | u, v V}). The edges e1 and e2 are multiple edges if f(e1) = f(e2).

  • Example of a Directed MultigraphThe algorithm uses a finite number of steps, since it terminates after all the integers in the sequence have been examined.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 540

  • Graph TerminologyDiscrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 540

    TypeEdgesMultiple Edges Allowed?Loops Allowed?Simple GraphUndirectedNoNoMultigraphUndirectedYesNoPseugographUndirectedYesYesDirected GraphDirectedNoYesDirected MultigraphDirectedYesYes

  • Niche Overlap Graphs in Ecology The competition between species in an ecosystem can be modeled using a niche overlap graph.

    Each species is represented by a vertex.

  • Niche Overlap Graphs in Ecology An undirected edge connects two vertices if the two species represented by these vertices compete. Two species are connected if the food resources they use are the same.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 541

  • Acquaintanceship GraphTo represent whether two people know each other (whether they are acquainted)Each person is represented by a vertex.

    An undirected edge connects two people when they know each other.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 541

  • Influence GraphIn studies of group behavior it is observed that certain people can influence the thinking of others.

    A directed graph can model this behavior.

    Each person is represented by a vertex.

    There is a directed vertex from vertex a to vertex b when person a influences person b.

  • Influence Graph (A Directed Graph)Deborah can influence Brian, Fred, and Linda, but no one can influence her.Yvonne and Brian can influence each other.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 542

  • Round-Robin Tournaments A tournament where each team plays each other team exactly once is called a round-robin tournament.

    In this case a directed graph is used.

    Each team is represented by a vertex.

  • Round-Robin Tournaments(a, b) is an edge if team a beats team b.

    Team 1 is undefeated in this tournament

    Team 3 is winless.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 542

  • Call GraphsGraphs can be used to model telephone calls made in a network, such as a long-distance telephone network.

    A directed multigraph can be used.

    Each telephone is a vertex

    Each telephone call is represented by a directed edge.

  • Call Graph using Directed GraphThree calls have been made from 732-555-1234 to 732-555-9876 and two in the other direction .Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 542

  • Call Graph using Directed GraphOne call has been made from 732-555-4444 to 732-555-0011.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 542

  • Call Graph using Undirected GraphAn undirected graph is used if there has been a call connecting two telephone numbers. Each edge tells us whether there has been a call between two numbers.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 542

  • Precedence Graph and Concurrent ProcessingComputer programs can be executed more rapidly by executing certain statements concurrently.

    It is important not to execute a statement that requires results of statement not yet executed.

  • Precedence Graph and Concurrent ProcessingThe dependence of statements on previous statements can be represented by a directed graph.

    There is an edge from one vertex to a second vertex if the statement represented by the second vertex cannot be executed before the statement represented by the first vertex has been executed.

  • Precedence Graph and Concurrent ProcessingIn this section of a computer program the statement S5 cannot be executed before S1, S2, and S4 are executed.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 543

  • Representing GraphsTo represent a graph without multiple edges is to list all the edges of this graph.

    To represent a graph with no multiple edges is to use adjacent list, which specify the vertices that are adjacent to each vertex of the graph.

  • Example: Representing GraphsUse adjacent lists to describe the simple graph given in the figure.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 557

    VertexAdjacent Verticesab, c, ebaca, d, edc, eea, c, d

  • Example: Representing GraphsRepresent the directed graph shown in the figure by listing all the vertices that are the terminal vertices of edges starting at each vertex of the graph in the figure.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 558

    Initial VertexTerminal Verticesab, c, d, ebb, dca, c, edeb, c, d

  • The Adjacency Matrix A (AG)If A = {aij} is the adjacency matrix A of G, then aij = 1 if {vi, vj} is an edge of G and aij = 0 otherwise.The adjacency matrix of a simple graph is symmetric if aij = aji.A simple graph has no loops, so each entry aii = 1, 2, , n is 0.

  • Example: Adjacent MatrixUse an adjacent matrix to represent the graph.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 558

  • Example: Adjacent MatrixDraw a graph with the adjacent matrix with respect to ordering of vertices a, b, c, d.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 559

  • Example: Adjacent MatrixUse an adjacent matrix to represent the pseudograph shown in the figure.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 559

  • Incidence MatricesLet G = (V, E) be an undirected graph. Suppose that v1,v2, , vn are the vertices and e1, e2, , em are the edges of G.

    Then the incidence matrix with respect to this ordering of V and E is n x m matrix M = {mij}, where mij= 1 when edge ei is incident with vi, mij= 0 otherwise

  • Represent the graph with an incidence matrix.Example: Incidence MatrixDiscrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 560

  • Represent the pseudograph with an incidence matrix.Example: Incidence MatrixDiscrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 560

  • We often need to know whether it is possible to draw two graph in the same way.Isomorphism of GraphsIn chemistry different compounds can have the same molecular formula but can differ in structure.Such compounds will be represented by graph that cannot be drawn in the same way.

  • The simple graphs G1 = (V1, E1) and G2 = (V2, E2) are isomorphic if there is a one-to-one and onto function f from V1 to V2 ,

    a and b are adjacent in G1 if and only if f(a) and f(b) are adjacent in G2, for all a and b in V1. Isomorphism of Graphs

  • Two simple graphs are isomorphic, if there is a one-to-one correspondence between vertices of the two graphs that preserves the adjacency relationship.

    Isomorphism of simple graph is an equivalence relation.

    Isomorphism comes from the Greek root isos for equal and morphe for form.Isomorphism of Graphs

  • Show that the graphs G = (V, E) and H = (W, F) are isomorphicExample: Isomorphismf(u1)= v1, f(u2)= v4, f(u3)= v3, f(u4)= v2 Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 561There is a one-to-one correspondence between V and W.

  • Show that the graphs G = (V, E) and H = (W, F) are isomorphicExample: Isomorphism (cont.)The adjacent vertices in G are u1 and u2, u1 and u3, u2 and u4,u3 and u4Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 561

  • Show that the graphs G = (V, E) and H = (W, F) are isomorphicExample: Isomorphism (cont.)Each of the pairsf(u1)= v1 and f(u2)= v4f(u1)= v1 and f(u3)= v3f(u2)= v4 and f(u4)= v2f(u3)= v3 and f(u4)= v2

    are adjacent in H.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 561

  • Two simple graphs are not isomorphic, if they do not share a property that isomorphic simple graphs must both have.

    This property is called an invariant with respect to isomorphism of simple graph.

    Isomorphism of Graphs

  • Isomorphic simple graphs must have the same number of vertices, since there is a one-to-one correspondence between the sets of vertices of the graphs.

    Isomorphism: Some Invariants

  • Isomorphic simple graphs must have the same number of edges, because the one-to-one correspondence between vertices establishes a one-to-one correspondence between edges.Isomorphism of Graphs

  • The degree of the vertices in isomorphic simple graph must be the same.

    A vertex v of degree d in G must correspond to a vertex f(v) of degree d in H, since a vertex w in G is adjacent to v if and only if f(v) and f(w) are adjacent in H.

    Isomorphism of Graphs

  • Show that the graphs are not isomorphic.Examples of Graphs not IsomorphicG and H have 5 vertices and 6 edgesH has a vertex of degree one (e).G has no vertices of degree one.G and H are not isomorphic.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 561

  • Determine whether the graphs are isomorphic.Examples of Graphs not IsomorphicG and H have 8 vertices and 10 edges.

    G and H have 4 vertices of degree 2 and 4 of degree 3.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 561

  • Determine whether the graphs are isomorphic.Examples of Graphs not IsomorphicIn G deg(a) = 2, and a must correspond to either t, u, x , or y in H.

    t, u, x, and y are adjacent to another vertex of degree 2, which is not true for a in G.

    G and H are not isomorphic.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 561

  • Determine whether the graphs are isomorphic using subgraphs.Examples of Graphs not IsomorphicIn G deg(a) = 2, and a must correspond to either t, u, x , or y in H.

    t, u, x, and y are adjacent to another vertex of degree 2, which is not true for a in G. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 561

  • Determine whether the graphs are isomorphic using subgraphs.Examples of Graphs not IsomorphicDiscrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 562

  • Determine whether the graphs are isomorphic using subgraphs.Examples of Graphs not IsomorphicThe subgraphs of G and H made up of vertices of degree 3 and the edges connecting then must be isomorphic if these two graphs are isomorphic.

    G and H are not isomorphic.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 562

  • Determine whether the graphs are isomorphic using adjacency matrix.Examples of Graphs IsomorphicBoth G and H have 6 vertices and 7 edges.

    Both have four vertices of degree 2 and 2 vertices of degree three.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 562

  • Determine whether the graphs are isomorphic using adjacency matrix.Examples of Graphs IsomorphicDiscrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pp 562-563

  • Determine whether the graphs are isomorphic using adjacency matrix.Examples of Graphs IsomorphicDiscrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pp 562-563

  • Determine whether the graphs are isomorphic using adjacency matrix.Examples of Graphs Isomorphic AG = AH, G and H are isomorphic.Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. p 563

  • A path is a sequence of edges that begins at a vertex of a graph and travels along edges of the graph, always connecting pairs of adjacent vertices.Path

  • A walk in a pseudograph is an altering sequence of vertices and edges, beginning and ending with a vertex, in which each edge is incident with the vertex immediately preceding it and the vertex immediately following it.Walk

  • The length of a walk is the number of edges in it.

    A walk is closed if the first vertex is the same as the last and otherwise open.Walk

  • A trail is a walk in which all edges are distinct;

    A path is a walk in which all vertices are distinct.Trail

  • A closed trail is a circuit.

    A circuit in which the first vertex appears exactly twice (at the beginning and the end) and in which no other vertex appears more than once is a cycle.

    An n-cycle is a cycle with n vertices. It is even if n is even and odd if n is odd.Circuit

  • Terms and their characteristics

    TermCharacteristicsTrailDistinct edgesPath Distinct verticesCircuitClosed trailCycleClosed trail with distinct vertices (hence distinct edges too)

  • ExampleWalk : A B C E F C B D (length : 7)Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 305

  • ExampleTrail : A B C E F C D

    (distinct edges)Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 305

  • ExampleClosed walk : A B C E F C B D ADiscrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 305

  • ExampleCircuit : B C E F C D BDiscrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 305

  • Example3-cycle : B C D BDiscrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 305

  • ExampleA closed walk (not a cycle): C E F C B D CDiscrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 305

  • An Euler circuit in a graph G is a simple circuit containing every edge of G.

    An Euler path in G is a simple path containing every edge of G.An Eulerian or Euler Circuit

  • The graph G1 has an Euler circuit: a, e, c, d, e, b, a Example: An Eulerian CircuitDiscrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 578

  • The graph G2 and G3 dont have an Euler circuit. G3 has an Euler path:a, c, d, e, b, d, a, b

    G2 does not have an Euler path.Example: An Eulerian CircuitDiscrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 578

  • H2 has an Euler circuit:a, g, c, b, g, e, d, f, a

    H1 nor H3 has an Euler circuit.H3 has an Euler path: c, a, b, c, d, bH1 does not have an Euler path.Example: An Eulerian CircuitDiscrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 579

  • A connected multigraph has an Eulerian circuit if and only if each of its vertices has even degree.

    A connected multigraph has an Eulerian path but not an Eulerian circuit if and only if it has exactly two vertices of odd degree.An Eulerian Circuit

  • G1 contains two vertices of odd degree (b and d).

    b and d must be the end points of this Euler path.Example: Eulerian Pathd, a, b, c, d, b is an Euler path. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 582

  • G2 contains exactly two vertices of odd degree (b and d).

    b and d must be the end points of this Euler path.Example: Eulerian Pathb, a, g, f, e, d, c, g, b, c, f, d is an Euler path. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 582

  • G3 has six vertices of odd degree.

    G3 has no Euler path. Example: No Eulerian PathDiscrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 582

  • A Hamiltonian cycle in a graph is a cycle that contains every vertex of a graph.

    A Hamiltonian graph is one with a Hamiltonian cycle.

    A Hamiltonian circuit as a circuit in which every vertex except the first and last appears exactly once.Hamiltonian Cycles

  • A Hamiltonian circuit is a cycle.

    The terms Hamiltonian circuit and Hamiltonian cycle are synonymous.Hamiltonian Cycles

  • Hamiltonian CyclesCycle A B C D E A is HamiltonianG2 is not HamiltonianG1 is HamiltonianDiscrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 311

  • Many problems can be modeled using graphs with weights to their edges.

    Problems associated with edge is a unit of time, distance, cost, or capacity in some sense.Shortest Path Algorithm

  • A weighted graph is a graph G(V, E) together with a function w: E [0, ). If e is an edge, the nonnegative real number w(e) is called the weight of e.

    The weight of a subgraph of G (often a path or a trail) is the sum of the weights of the edges of the subgraph.Shortest Path Algorithm

  • A traveling salesman visits various towns and cities.

    If he wants to avoid having to pass through the same community twice, he needs a Hamiltonian cycle through the map of towns and air routs.The Traveling Salesmans Problem

  • A traveling salesman visits various towns and cities.

    If he wants to avoid having to pass through the same community twice, he needs a Hamiltonian cycle through the map of towns and air routs.The Traveling Salesmans Problem

  • To find a shortest path from vertex A to vertex E in a weighted graph.

    Step 1 Assign to A the label (_, 0).

    Step 2 Until E or no further labels can be assigned, do the following.

    For each labeled vertex u(x, d) and for each unlabeled vertex v adjacent to u, compute d+w(e) where e = uv.Dijkstras Algorithm

  • b) Find the minimum value d of all numbers d + w(e) found in a).

    c) For each u and v for which d + w(e) = d, assign to v the label (u, d). If a vertex can be labeled (x, d) for various vertices x, make any choice. Dijkstras Algorithm

  • Example: Dijkstras AlgorithmGive A the label (_, 0). There are 3 edges incident with A with weights 7, 5, and 8. d = 0Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 328

  • Example: Dijkstras AlgorithmSince d = 0, vertex H gives the smallest value of d + w(e), H acquires the label (A, 5), G the label (A, 8), and B the label (A, 7) because they are the smallest d + w(e).Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 328

  • Example: Dijkstras AlgorithmVertex I and C give the smallest value of d + w(e), I acquires the label (B, 10), and C the label (B, 15)Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 328

  • Example: Dijkstras AlgorithmVertex J, D and F give the smallest value of d + w(e), J acquires the label (I, 17), D the label (J, 20), and F the label (D, 15).Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 328

  • Example: Dijkstras AlgorithmVertex E gives the smallest value of d + w(e), E acquires the label (F, 21).Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 328

  • Example: Dijkstras AlgorithmThe shortest route from A to E has weight 21. A shortest path is AGFE.Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 328

  • To find a shortest path from vertex A to vertex E in a weighted graph.

    Step 1 Set v1 = A and assign to this vertex the permanent label 0. Assign every other vertex a temporary label of , where is a symbol that, by definition, is deemed to be larger that any real number.

    Step 2 Until E has been assigned a permanent label or no temporary labels are changed in (a) or (b) do the following:Dijkstras Algorithm (Improved)

  • Take the vertex vi that most recently acquired a permanent label, say d. For each vertex v that is adjacent to vi and has not yet received a permanent label, if d + w(vi, v) < t, the current temporary label of v, change the temporary label of v to d + w(vi, v).

    Take a vertex v that has a temporary label smallest among all temporary labels in the graph. Set vi+1 = v and make its temporary label permanent. If there are several vertices v that tie for smallest temporary label, make any choice.Dijkstras Algorithm (Improved)

  • At the start, A = v1 is given the permanent label 0, all the others are given temporary label Dijkstras Algorithm (Improved)Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

  • Next, H, B, and G have their temporary labels decreased to 5, 7, and 8, respectively, all other temporary labels stay at .Dijkstras Algorithm (Improved)Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

  • Since 5 is the minimum of 5, 7, 8, set v2 = H, The vertices adjacent to v2. For B, 5 + 4 = 9, 9 > 7, so no change occurs. For G, 5 + 5 = 10, 10 > 8. so no change occurs, set v3 = B.Dijkstras Algorithm (Improved)Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

  • The vertices adjacent to v3. For C, 7 + 8 = 15. For I, 7 + 3 = 10. Now C, I, and G have their temporary labels 15, 10, 8, respectively. The smallest is 8. so v4 = G.Dijkstras Algorithm (Improved)Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

  • The vertices adjacent to v4. For I, 8 + 2 = 10, the current label , so there is no change. For F, 8 + 7 = 15, so F gets a temporary label of 15 and set v5 = IDijkstras Algorithm (Improved)Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

  • Next, we have a choice of C or F for v6 and J gets a temporary label 17. Assuming v6= C, then F = v7 and D obtains a temporary label 23.Dijkstras Algorithm (Improved)Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

  • Finally, v10 = 21. Then D gets its temporary label lowered to 20 and becomes v9.Dijkstras Algorithm (Improved)Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

  • This algorithm gives the length of the shortest path but not the path itself.Dijkstras Algorithm (Improved)Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

  • This algorithm gives the length of the shortest path but not the path itself.

    (permanent label of vl) + (weight of edge vlvi) = (permanent label of vi)Dijkstras Algorithm (Improved)

  • Topics coveredGraph. Definitions and basic properties.

    Adjacency matrices.

    Isomorphism.

  • Topics coveredPath, walk, circuit, and cycle.

    Eulerian circuits.

    Hamilton cycles.

    Shortest path algorithms: Dijkstras Algorithm.

  • ReferenceDiscrete Mathematics with Graph Theory, Third Edition, E. Goodaire and Michael Parmenter, Pearson Prentice Hall, 2006. pp 281-303.

  • ReferenceDiscrete Mathematics and Its Applications, Fifth Edition, Kenneth H. Rosen, McGraw-Hill, 2003. pp 281-567.