• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Discrete Mathematics - Graphs
 

Discrete Mathematics - Graphs

on

  • 15,359 views

Graphs, digraphs, isomorphism, connectivity, traversable graphs, planar graphs. Trees, rooted trees, binary trees, decision trees. Weighted graphs, shortest path, miminum spanning tree.

Graphs, digraphs, isomorphism, connectivity, traversable graphs, planar graphs. Trees, rooted trees, binary trees, decision trees. Weighted graphs, shortest path, miminum spanning tree.

Statistics

Views

Total Views
15,359
Views on SlideShare
15,357
Embed Views
2

Actions

Likes
7
Downloads
437
Comments
2

2 Embeds 2

http://www.docshut.com 1
http://www.slashdocs.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

12 of 2 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Discrete Mathematics - Graphs Discrete Mathematics - Graphs Presentation Transcript

    • Discrete MathematicsGraphsH. Turgut Uyar Ay¸seg¨ul Gen¸cata Yayımlı Emre Harmancı2001-2013
    • Licensec 2001-2013 T. Uyar, A. Yayımlı, E. HarmancıYou are free:to Share – to copy, distribute and transmit the workto Remix – to adapt the workUnder the following conditions:Attribution – You must attribute the work in the manner specified by the author or licensor (but not in anyway that suggests that they endorse you or your use of the work).Noncommercial – You may not use this work for commercial purposes.Share Alike – If you alter, transform, or build upon this work, you may distribute the resulting work onlyunder the same or similar license to this one.Legal code (the full license):http://creativecommons.org/licenses/by-nc-sa/3.0/
    • Topics1 GraphsIntroductionConnectivityPlanar GraphsSearching Graphs2 TreesIntroductionRooted TreesBinary TreesDecision Trees3 Weighted GraphsIntroductionShortest PathMinimum Spanning Tree
    • Topics1 GraphsIntroductionConnectivityPlanar GraphsSearching Graphs2 TreesIntroductionRooted TreesBinary TreesDecision Trees3 Weighted GraphsIntroductionShortest PathMinimum Spanning Tree
    • GraphsDefinitiongraph: G = (V , E)V : node (or vertex) setE ⊆ V × V : edge setif e = (v1, v2) ∈ E:v1 and v2 are endnodes of ee is incident to v1 and v2v1 and v2 are adjacentnode with no incident edge: isolated node
    • GraphsDefinitiongraph: G = (V , E)V : node (or vertex) setE ⊆ V × V : edge setif e = (v1, v2) ∈ E:v1 and v2 are endnodes of ee is incident to v1 and v2v1 and v2 are adjacentnode with no incident edge: isolated node
    • Graph ExampleExampleV = {a, b, c, d, e, f }E = {(a, b), (a, c),(a, d), (a, e),(a, f ), (b, c),(d, e), (e, f )}
    • Directed GraphsDefinitiondirected graph (or digraph): D = (V , A)A ⊆ V × V : arc setorigin and terminating nodes
    • Directed Graph ExampleExample
    • MultigraphsDefinitionparallel edges: edges between the same pair of nodesloop: an edge starting and ending in the same nodeplain graph: a graph without any loops or parallel edgesmultigraph: a graph which is not plain
    • MultigraphsDefinitionparallel edges: edges between the same pair of nodesloop: an edge starting and ending in the same nodeplain graph: a graph without any loops or parallel edgesmultigraph: a graph which is not plain
    • Multigraph ExampleExampleparallel edges:(a, b)loop:(e, e)
    • SubgraphDefinitionG = (V , E ) is a subgraph of G = (V , E):V ⊆ VE ⊆ E∀(v1, v2) ∈ E v1, v2 ∈ V
    • Representationincidence matrix:rows represent nodes, columns represent edgescell: 1 if the edge is incident to the node, 0 otherwiseadjacency matrix:rows and columns represent nodescells represent the number of edges between the nodes
    • Representationincidence matrix:rows represent nodes, columns represent edgescell: 1 if the edge is incident to the node, 0 otherwiseadjacency matrix:rows and columns represent nodescells represent the number of edges between the nodes
    • Incidence Matrix ExampleExamplee1 e2 e3 e4 e5 e6 e7 e8v1 1 1 1 0 1 0 0 0v2 1 0 0 1 0 0 0 0v3 0 0 1 1 0 0 1 1v4 0 0 0 0 1 1 0 1v5 0 1 0 0 0 1 1 0
    • Adjacency Matrix ExampleExamplev1 v2 v3 v4 v5v1 0 1 1 1 1v2 1 0 1 0 0v3 1 1 0 1 1v4 1 0 1 0 1v5 1 0 1 1 0
    • Adjacency Matrix ExampleExamplea b c da 0 0 0 1b 2 1 1 0c 0 0 0 0d 0 1 1 0
    • DegreeDefinitiondegree: number of edges incident to the nodeTheoremlet di be the degree of node vi|E| = i di2
    • DegreeDefinitiondegree: number of edges incident to the nodeTheoremlet di be the degree of node vi|E| = i di2
    • Degree ExampleExample (plain graph)da = 5db = 2dc = 2dd = 2de = 3df = 2Total = 16|E| = 8
    • Degree ExampleExample (multigraph)da = 6db = 3dc = 2dd = 2de = 5df = 2Total = 20|E| = 10
    • Degree in Directed Graphstwo types of degreein-degree: dviout-degree: dvonode with in-degree 0: sourcenode with out-degree 0: sinkv∈V dvi= v∈V dvo= |A|
    • Degree in Directed Graphstwo types of degreein-degree: dviout-degree: dvonode with in-degree 0: sourcenode with out-degree 0: sinkv∈V dvi= v∈V dvo= |A|
    • Degree in Directed Graphstwo types of degreein-degree: dviout-degree: dvonode with in-degree 0: sourcenode with out-degree 0: sinkv∈V dvi= v∈V dvo= |A|
    • DegreeTheoremIn an undirected graph, there is an even number of nodeswhich have an odd degree.Proof.ti : number of nodes of degree i2|E| = i di = 1t1 + 2t2 + 3t3 + 4t4 + 5t5 + . . .2|E| − 2t2 − 4t4 − · · · = t1 + t3 + · · · + 2t3 + 4t5 + . . .2|E| − 2t2 − 4t4 − · · · − 2t3 − 4t5 − · · · = t1 + t3 + t5 + . . .since the left-hand side is even, the right-hand side is also even
    • DegreeTheoremIn an undirected graph, there is an even number of nodeswhich have an odd degree.Proof.ti : number of nodes of degree i2|E| = i di = 1t1 + 2t2 + 3t3 + 4t4 + 5t5 + . . .2|E| − 2t2 − 4t4 − · · · = t1 + t3 + · · · + 2t3 + 4t5 + . . .2|E| − 2t2 − 4t4 − · · · − 2t3 − 4t5 − · · · = t1 + t3 + t5 + . . .since the left-hand side is even, the right-hand side is also even
    • DegreeTheoremIn an undirected graph, there is an even number of nodeswhich have an odd degree.Proof.ti : number of nodes of degree i2|E| = i di = 1t1 + 2t2 + 3t3 + 4t4 + 5t5 + . . .2|E| − 2t2 − 4t4 − · · · = t1 + t3 + · · · + 2t3 + 4t5 + . . .2|E| − 2t2 − 4t4 − · · · − 2t3 − 4t5 − · · · = t1 + t3 + t5 + . . .since the left-hand side is even, the right-hand side is also even
    • DegreeTheoremIn an undirected graph, there is an even number of nodeswhich have an odd degree.Proof.ti : number of nodes of degree i2|E| = i di = 1t1 + 2t2 + 3t3 + 4t4 + 5t5 + . . .2|E| − 2t2 − 4t4 − · · · = t1 + t3 + · · · + 2t3 + 4t5 + . . .2|E| − 2t2 − 4t4 − · · · − 2t3 − 4t5 − · · · = t1 + t3 + t5 + . . .since the left-hand side is even, the right-hand side is also even
    • DegreeTheoremIn an undirected graph, there is an even number of nodeswhich have an odd degree.Proof.ti : number of nodes of degree i2|E| = i di = 1t1 + 2t2 + 3t3 + 4t4 + 5t5 + . . .2|E| − 2t2 − 4t4 − · · · = t1 + t3 + · · · + 2t3 + 4t5 + . . .2|E| − 2t2 − 4t4 − · · · − 2t3 − 4t5 − · · · = t1 + t3 + t5 + . . .since the left-hand side is even, the right-hand side is also even
    • DegreeTheoremIn an undirected graph, there is an even number of nodeswhich have an odd degree.Proof.ti : number of nodes of degree i2|E| = i di = 1t1 + 2t2 + 3t3 + 4t4 + 5t5 + . . .2|E| − 2t2 − 4t4 − · · · = t1 + t3 + · · · + 2t3 + 4t5 + . . .2|E| − 2t2 − 4t4 − · · · − 2t3 − 4t5 − · · · = t1 + t3 + t5 + . . .since the left-hand side is even, the right-hand side is also even
    • Regular GraphsDefinitionregular graph: all nodes have the same degreen-regular: all nodes have degree n
    • Regular Graph ExamplesExample
    • Completely Connected GraphsDefinitionG = (V , E) is completely connected:∀v1, v2 ∈ V (v1, v2) ∈ Ethere is an edge between every pair of nodesKn: the completely connected graph with n nodes
    • Completely Connected GraphsDefinitionG = (V , E) is completely connected:∀v1, v2 ∈ V (v1, v2) ∈ Ethere is an edge between every pair of nodesKn: the completely connected graph with n nodes
    • Completely Connected Graph ExamplesExample (K4)Example (K5)
    • Bipartite GraphsDefinitionG = (V , E) is bipartite:∀(v1, v2) ∈ E v1 ∈ V1 ∧ v2 ∈ V2V1 ∪ V2 = V , V1 ∩ V2 = ∅complete bipartite: ∀v1 ∈ V1 ∀v2 ∈ V2 (v1, v2) ∈ EKm,n: |V1| = m, |V2| = n
    • Bipartite GraphsDefinitionG = (V , E) is bipartite:∀(v1, v2) ∈ E v1 ∈ V1 ∧ v2 ∈ V2V1 ∪ V2 = V , V1 ∩ V2 = ∅complete bipartite: ∀v1 ∈ V1 ∀v2 ∈ V2 (v1, v2) ∈ EKm,n: |V1| = m, |V2| = n
    • Complete Bipartite Graph ExamplesExample (K2,3) Example (K3,3)
    • IsomorphismDefinitionG = (V , E) and G = (V , E ) are isomorphic:∃f : V → V (u, v) ∈ E ⇒ (f (u), f (v)) ∈ Ef is bijectiveG and G can be drawn the same way
    • IsomorphismDefinitionG = (V , E) and G = (V , E ) are isomorphic:∃f : V → V (u, v) ∈ E ⇒ (f (u), f (v)) ∈ Ef is bijectiveG and G can be drawn the same way
    • Isomorphism ExampleExamplef = {(a, d), (b, e), (c, b), (d, c), (e, a)}
    • Isomorphism ExampleExamplef = {(a, d), (b, e), (c, b), (d, c), (e, a)}
    • Isomorphism ExampleExample (Petersen graph)f = {(a, q), (b, v), (c, u), (d, y), (e, r),(f , w), (g, x), (h, t), (i, z), (j, s)}
    • HomeomorphismDefinitionG = (V , E) and G = (V , E ) are homeomorphic:G and G are isomorphic except thatsome edges in E are divided with additional nodes
    • Homeomorphism ExampleExample
    • Topics1 GraphsIntroductionConnectivityPlanar GraphsSearching Graphs2 TreesIntroductionRooted TreesBinary TreesDecision Trees3 Weighted GraphsIntroductionShortest PathMinimum Spanning Tree
    • WalkDefinitionwalk: a sequence of nodes and edgesfrom a starting node (v0) to an ending node (vn)v0, e1, v1, e2, v2, e3, v3, . . . , en−1, vn−1, en, vnwhere ei = (vi−1, vi )no need to write the edgeslength: number of edges in the walkif v0 = vn open, if v0 = vn closed
    • WalkDefinitionwalk: a sequence of nodes and edgesfrom a starting node (v0) to an ending node (vn)v0, e1, v1, e2, v2, e3, v3, . . . , en−1, vn−1, en, vnwhere ei = (vi−1, vi )no need to write the edgeslength: number of edges in the walkif v0 = vn open, if v0 = vn closed
    • WalkDefinitionwalk: a sequence of nodes and edgesfrom a starting node (v0) to an ending node (vn)v0, e1, v1, e2, v2, e3, v3, . . . , en−1, vn−1, en, vnwhere ei = (vi−1, vi )no need to write the edgeslength: number of edges in the walkif v0 = vn open, if v0 = vn closed
    • Walk ExampleExample(c, b), (b, a), (a, d), (d, e),(e, f ), (f , a), (a, b)c, b, a, d, e, f , a, blength: 7
    • TrailDefinitiontrail: a walk where edges are not repeatedcircuit: closed trailspanning trail: a trail that covers all the edges in the graph
    • TrailDefinitiontrail: a walk where edges are not repeatedcircuit: closed trailspanning trail: a trail that covers all the edges in the graph
    • Trail ExampleExample(c, b), (b, a), (a, e), (e, d),(d, a), (a, f )c, b, a, e, d, a, f
    • PathDefinitionpath: a walk where nodes are not repeatedcycle: closed pathspanning path: a path that visits all the nodes in the graph
    • PathDefinitionpath: a walk where nodes are not repeatedcycle: closed pathspanning path: a path that visits all the nodes in the graph
    • Path ExampleExample(c, b), (b, a), (a, d), (d, e),(e, f )c, b, a, d, e, f
    • ConnectivityDefinitionconnected graph: there is a path between every pair of nodesa disconnected graph can be dividedinto connected components
    • ConnectivityDefinitionconnected graph: there is a path between every pair of nodesa disconnected graph can be dividedinto connected components
    • Connected Components ExampleExamplegraph is disconnected:no path between a and cconnected components:a, d, eb, cf
    • DistanceDefinitionthe distance between nodes vi and vj :the length of the shortest path between vi and vjDefinitiondiameter: the largest distance in the graph
    • DistanceDefinitionthe distance between nodes vi and vj :the length of the shortest path between vi and vjDefinitiondiameter: the largest distance in the graph
    • Distance ExampleExampledistance between a and e: 2diameter: 3
    • Distance ExampleExampledistance between a and e: 2diameter: 3
    • Cut-PointDefinitionG − v:the graph obtained by deleting the node vand all its incident edges from the graph GDefinitionv is a cut-point for G:G is connected but G − v is disconnected
    • Cut-PointDefinitionG − v:the graph obtained by deleting the node vand all its incident edges from the graph GDefinitionv is a cut-point for G:G is connected but G − v is disconnected
    • Cut-Point ExampleG G − d
    • Directed Walkssame as in undirected graphsignoring the directions on the arcs:semi-walk, semi-trail, semi-path
    • Weakly Connected GraphDefinitionweakly connected:there is a semi-pathbetween every pair of nodesExample
    • Unilaterally Connected GraphDefinitionunilaterally connected:for every pair of nodes, there isa path from one to the otherExample
    • Strongly Connected GraphDefinitionstrongly connected:there is a path in both directionsbetween every pair of nodesExample
    • Bridges of K¨onigsbergcross each bridge exactly onceand return to the starting point
    • Traversable GraphsDefinitionG is traversable: G contains a spanning trail
    • Traversable Graphsa node with an odd degree must be either the starting nodeor the ending node of the trailall nodes except the starting node and the ending nodemust have even degrees
    • Traversable Graph ExampleExampledegrees of a, b and c are evendegrees of d and e are odda spanning trail can be formedstarting from node d andending at node e (or vice versa):d, b, a, c, e, d, c, b, e
    • Traversable Graph ExampleExampledegrees of a, b and c are evendegrees of d and e are odda spanning trail can be formedstarting from node d andending at node e (or vice versa):d, b, a, c, e, d, c, b, e
    • Bridges of K¨onigsbergall node have odd degrees: not traversable
    • Euler GraphsDefinitionEuler graph: a graph that contains a closed spanning trailG is an Euler graph ⇔ the degrees of all nodes in G are even
    • Euler Graph ExamplesExample (Euler graph) Example (not an Euler graph)
    • Hamilton GraphsDefinitionHamilton graph: a graph that contains a closed spanning path
    • Hamilton Graph ExamplesExample (Hamilton graph) Example (not a Hamilton graph)
    • Connectivity Matrixif the adjacency matrix of the graph is A,the (i, j) element of Ak shows the number of walks of length kbetween the nodes i and jin an undirected graph with n nodes,the distance between two nodes is at most n − 1connectivity matrix:C = A1 + A2 + A3 + · · · + An−1if all elements are non-zero, then the graph is connected
    • Connectivity Matrixif the adjacency matrix of the graph is A,the (i, j) element of Ak shows the number of walks of length kbetween the nodes i and jin an undirected graph with n nodes,the distance between two nodes is at most n − 1connectivity matrix:C = A1 + A2 + A3 + · · · + An−1if all elements are non-zero, then the graph is connected
    • Connectivity Matrixif the adjacency matrix of the graph is A,the (i, j) element of Ak shows the number of walks of length kbetween the nodes i and jin an undirected graph with n nodes,the distance between two nodes is at most n − 1connectivity matrix:C = A1 + A2 + A3 + · · · + An−1if all elements are non-zero, then the graph is connected
    • Warshall’s Algorithmit is easier to find whether there is a walk between two nodesinstead of finding the number of walksfor each node:from all nodes which can reach the chosen node(the rows that contain 1 in the chosen column)to the nodes which can be reached from the chosen node(the columns that contain 1 in the chosen row)
    • Warshall’s Algorithmit is easier to find whether there is a walk between two nodesinstead of finding the number of walksfor each node:from all nodes which can reach the chosen node(the rows that contain 1 in the chosen column)to the nodes which can be reached from the chosen node(the columns that contain 1 in the chosen row)
    • Warshall’s Algorithm ExampleExamplea b c da 0 1 0 0b 0 1 0 0c 0 0 0 1d 1 0 1 0
    • Warshall’s Algorithm ExampleExamplea b c da 0 1 0 0b 0 1 0 0c 0 0 0 1d 1 1 1 0
    • Warshall’s Algorithm ExampleExamplea b c da 0 1 0 0b 0 1 0 0c 0 0 0 1d 1 1 1 0
    • Warshall’s Algorithm ExampleExamplea b c da 0 1 0 0b 0 1 0 0c 0 0 0 1d 1 1 1 1
    • Warshall’s Algorithm ExampleExamplea b c da 0 1 0 0b 0 1 0 0c 1 1 1 1d 1 1 1 1
    • Topics1 GraphsIntroductionConnectivityPlanar GraphsSearching Graphs2 TreesIntroductionRooted TreesBinary TreesDecision Trees3 Weighted GraphsIntroductionShortest PathMinimum Spanning Tree
    • Planar GraphsDefinitionA graph is planar if it can be drawn on a planewithout intersecting its edges.a map of G: a planar drawing of G
    • Planar Graph ExampleExample (K4)
    • Regionsa map divides the plane into regionsthe degree of a region:the length of the closed trail that surrounds the regionTheoremlet dribe the degree of region ri|E| = i dri2
    • Regionsa map divides the plane into regionsthe degree of a region:the length of the closed trail that surrounds the regionTheoremlet dribe the degree of region ri|E| = i dri2
    • Region ExampleExampledr1 = 3 (abda)dr2 = 3 (bcdb)dr3 = 5 (cdefec)dr4 = 4 (abcea)dr5 = 3 (adea)r dr = 18|E| = 9
    • Euler’s FormulaTheorem (Euler’s Formula)Let G = (V , E) be a planar, connected graphand let R be the set of regions in a map of G:|V | − |E| + |R| = 2
    • Euler’s Formula ExampleExample|V | = 6, |E| = 9, |R| = 5
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:|E| ≤ 3|V | − 6Proof.the sum of region degrees: 2|E|degree of a region is at least 3⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 23|E||V | − |E| + |R| = 2⇒ |V | − |E| + 23|E| ≥ 2 ⇒ |V | − 13|E| ≥ 2⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:|E| ≤ 3|V | − 6Proof.the sum of region degrees: 2|E|degree of a region is at least 3⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 23|E||V | − |E| + |R| = 2⇒ |V | − |E| + 23|E| ≥ 2 ⇒ |V | − 13|E| ≥ 2⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:|E| ≤ 3|V | − 6Proof.the sum of region degrees: 2|E|degree of a region is at least 3⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 23|E||V | − |E| + |R| = 2⇒ |V | − |E| + 23|E| ≥ 2 ⇒ |V | − 13|E| ≥ 2⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:|E| ≤ 3|V | − 6Proof.the sum of region degrees: 2|E|degree of a region is at least 3⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 23|E||V | − |E| + |R| = 2⇒ |V | − |E| + 23|E| ≥ 2 ⇒ |V | − 13|E| ≥ 2⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:|E| ≤ 3|V | − 6Proof.the sum of region degrees: 2|E|degree of a region is at least 3⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 23|E||V | − |E| + |R| = 2⇒ |V | − |E| + 23|E| ≥ 2 ⇒ |V | − 13|E| ≥ 2⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:|E| ≤ 3|V | − 6Proof.the sum of region degrees: 2|E|degree of a region is at least 3⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 23|E||V | − |E| + |R| = 2⇒ |V | − |E| + 23|E| ≥ 2 ⇒ |V | − 13|E| ≥ 2⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:|E| ≤ 3|V | − 6Proof.the sum of region degrees: 2|E|degree of a region is at least 3⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 23|E||V | − |E| + |R| = 2⇒ |V | − |E| + 23|E| ≥ 2 ⇒ |V | − 13|E| ≥ 2⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:|E| ≤ 3|V | − 6Proof.the sum of region degrees: 2|E|degree of a region is at least 3⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 23|E||V | − |E| + |R| = 2⇒ |V | − |E| + 23|E| ≥ 2 ⇒ |V | − 13|E| ≥ 2⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:|E| ≤ 3|V | − 6Proof.the sum of region degrees: 2|E|degree of a region is at least 3⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 23|E||V | − |E| + |R| = 2⇒ |V | − |E| + 23|E| ≥ 2 ⇒ |V | − 13|E| ≥ 2⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:|E| ≤ 3|V | − 6Proof.the sum of region degrees: 2|E|degree of a region is at least 3⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 23|E||V | − |E| + |R| = 2⇒ |V | − |E| + 23|E| ≥ 2 ⇒ |V | − 13|E| ≥ 2⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:∃v ∈ V dv ≤ 5Proof.let ∀v ∈ V dv ≥ 6⇒ 2|E| ≥ 6|V |⇒ |E| ≥ 3|V |⇒ |E| > 3|V | − 6
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:∃v ∈ V dv ≤ 5Proof.let ∀v ∈ V dv ≥ 6⇒ 2|E| ≥ 6|V |⇒ |E| ≥ 3|V |⇒ |E| > 3|V | − 6
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:∃v ∈ V dv ≤ 5Proof.let ∀v ∈ V dv ≥ 6⇒ 2|E| ≥ 6|V |⇒ |E| ≥ 3|V |⇒ |E| > 3|V | − 6
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:∃v ∈ V dv ≤ 5Proof.let ∀v ∈ V dv ≥ 6⇒ 2|E| ≥ 6|V |⇒ |E| ≥ 3|V |⇒ |E| > 3|V | − 6
    • Planar Graph TheoremsTheoremLet G = (V , E) be a connected, planar graph where |V | ≥ 3:∃v ∈ V dv ≤ 5Proof.let ∀v ∈ V dv ≥ 6⇒ 2|E| ≥ 6|V |⇒ |E| ≥ 3|V |⇒ |E| > 3|V | − 6
    • Nonplanar GraphsTheoremK5 is not planar.Proof.|V | = 53|V | − 6 = 3 · 5 − 6 = 9|E| ≤ 9 should holdbut |E| = 10
    • Nonplanar GraphsTheoremK5 is not planar.Proof.|V | = 53|V | − 6 = 3 · 5 − 6 = 9|E| ≤ 9 should holdbut |E| = 10
    • Nonplanar GraphsTheoremK5 is not planar.Proof.|V | = 53|V | − 6 = 3 · 5 − 6 = 9|E| ≤ 9 should holdbut |E| = 10
    • Nonplanar GraphsTheoremK5 is not planar.Proof.|V | = 53|V | − 6 = 3 · 5 − 6 = 9|E| ≤ 9 should holdbut |E| = 10
    • Nonplanar GraphsTheoremK5 is not planar.Proof.|V | = 53|V | − 6 = 3 · 5 − 6 = 9|E| ≤ 9 should holdbut |E| = 10
    • Nonplanar GraphsTheoremK3,3 is not planar. Proof.|V | = 6, |E| = 9if planar then |R| = 5degree of a region is at least 4⇒ r∈R dr ≥ 20|E| ≥ 10 should holdbut |E| = 9
    • Nonplanar GraphsTheoremK3,3 is not planar. Proof.|V | = 6, |E| = 9if planar then |R| = 5degree of a region is at least 4⇒ r∈R dr ≥ 20|E| ≥ 10 should holdbut |E| = 9
    • Nonplanar GraphsTheoremK3,3 is not planar. Proof.|V | = 6, |E| = 9if planar then |R| = 5degree of a region is at least 4⇒ r∈R dr ≥ 20|E| ≥ 10 should holdbut |E| = 9
    • Nonplanar GraphsTheoremK3,3 is not planar. Proof.|V | = 6, |E| = 9if planar then |R| = 5degree of a region is at least 4⇒ r∈R dr ≥ 20|E| ≥ 10 should holdbut |E| = 9
    • Nonplanar GraphsTheoremK3,3 is not planar. Proof.|V | = 6, |E| = 9if planar then |R| = 5degree of a region is at least 4⇒ r∈R dr ≥ 20|E| ≥ 10 should holdbut |E| = 9
    • Nonplanar GraphsTheoremK3,3 is not planar. Proof.|V | = 6, |E| = 9if planar then |R| = 5degree of a region is at least 4⇒ r∈R dr ≥ 20|E| ≥ 10 should holdbut |E| = 9
    • Kuratowski’s TheoremTheoremG contains a subgraph homeomorphic to K5 or K3,3.⇔G is not planar.
    • Platonic Solidsregular polyhedron: a 3-dimensional solidwhere the faces are identical regular polygonsthe projection of a regular polyhedron onto the planeis a planar graphevery corner is a nodeevery side is an edgeevery face is a region
    • Platonic Solidsregular polyhedron: a 3-dimensional solidwhere the faces are identical regular polygonsthe projection of a regular polyhedron onto the planeis a planar graphevery corner is a nodeevery side is an edgeevery face is a region
    • Platonic SolidsExample (cube)
    • Platonic Solidsv: number of corners (nodes)e: number of sides (edges)r: number of faces (regions)n: number of faces meeting at a corner (node degree)m: number of sides of a face (region degree)m, n ≥ 32e = n · v2e = m · r
    • Platonic Solidsv: number of corners (nodes)e: number of sides (edges)r: number of faces (regions)n: number of faces meeting at a corner (node degree)m: number of sides of a face (region degree)m, n ≥ 32e = n · v2e = m · r
    • Platonic Solidsfrom Euler’s formula:2 = v − e + r =2en− e +2em= e2m − mn + 2nmn> 0e, m, n > 0:2m − mn + 2n > 0 ⇒ mn − 2m − 2n < 0⇒ mn − 2m − 2n + 4 < 4 ⇒ (m − 2)(n − 2) < 4the values that satisfy this inequation:1 m = 3, n = 32 m = 4, n = 33 m = 3, n = 44 m = 5, n = 35 m = 3, n = 5
    • Platonic Solidsfrom Euler’s formula:2 = v − e + r =2en− e +2em= e2m − mn + 2nmn> 0e, m, n > 0:2m − mn + 2n > 0 ⇒ mn − 2m − 2n < 0⇒ mn − 2m − 2n + 4 < 4 ⇒ (m − 2)(n − 2) < 4the values that satisfy this inequation:1 m = 3, n = 32 m = 4, n = 33 m = 3, n = 44 m = 5, n = 35 m = 3, n = 5
    • Platonic Solidsfrom Euler’s formula:2 = v − e + r =2en− e +2em= e2m − mn + 2nmn> 0e, m, n > 0:2m − mn + 2n > 0 ⇒ mn − 2m − 2n < 0⇒ mn − 2m − 2n + 4 < 4 ⇒ (m − 2)(n − 2) < 4the values that satisfy this inequation:1 m = 3, n = 32 m = 4, n = 33 m = 3, n = 44 m = 5, n = 35 m = 3, n = 5
    • Platonic Solidsfrom Euler’s formula:2 = v − e + r =2en− e +2em= e2m − mn + 2nmn> 0e, m, n > 0:2m − mn + 2n > 0 ⇒ mn − 2m − 2n < 0⇒ mn − 2m − 2n + 4 < 4 ⇒ (m − 2)(n − 2) < 4the values that satisfy this inequation:1 m = 3, n = 32 m = 4, n = 33 m = 3, n = 44 m = 5, n = 35 m = 3, n = 5
    • Platonic Solidsfrom Euler’s formula:2 = v − e + r =2en− e +2em= e2m − mn + 2nmn> 0e, m, n > 0:2m − mn + 2n > 0 ⇒ mn − 2m − 2n < 0⇒ mn − 2m − 2n + 4 < 4 ⇒ (m − 2)(n − 2) < 4the values that satisfy this inequation:1 m = 3, n = 32 m = 4, n = 33 m = 3, n = 44 m = 5, n = 35 m = 3, n = 5
    • Tetrahedronm = 3, n = 3
    • Hexahedronm = 4, n = 3
    • Octahedronm = 3, n = 4
    • Dodecahedronm = 5, n = 3
    • Icosahedronm = 3, n = 5
    • Graph ColoringDefinitionproper coloring of G = (V , E): f : V → Cwhere C is a set of colors∀(vi , vj ) ∈ E f (vi ) = f (vj )minimizing |C|
    • Graph Coloring ExampleExamplea company produces chemical compoundssome compounds cannot be stored togethersuch compounds must be placed in separate storage areasstore the compounds using the least number of storage areas
    • Graph Coloring ExampleExamplea company produces chemical compoundssome compounds cannot be stored togethersuch compounds must be placed in separate storage areasstore the compounds using the least number of storage areas
    • Graph ColoringExampleevery compound is a nodetwo compounds that cannot be stored together are adjacent
    • Graph Coloring ExampleExample
    • Graph Coloring ExampleExample
    • Graph Coloring ExampleExample
    • Graph Coloring ExampleExample
    • Chromatic NumberDefinitionchromatic number of G: χ(G)the minimum number of colors needed to color the graph Gcalculating χ(G) is a very difficult problemχ(Kn) = n
    • Chromatic NumberDefinitionchromatic number of G: χ(G)the minimum number of colors needed to color the graph Gcalculating χ(G) is a very difficult problemχ(Kn) = n
    • Chromatic Number ExampleExample (Herschel graph)chromatic number: 2
    • Graph Coloring ExampleExample (Sudoku)every cell is a nodecells of the same roware adjacentcells of the same columnare adjacentcells of the same 3 × 3 blockare adjacentevery number is a colorproblem: properly color a graphthat is partially colored
    • Graph Coloring ExampleExample (Sudoku)every cell is a nodecells of the same roware adjacentcells of the same columnare adjacentcells of the same 3 × 3 blockare adjacentevery number is a colorproblem: properly color a graphthat is partially colored
    • Region Coloringcoloring a map by assigning different colors to adjacent regionsTheorem (Four Color Theorem)The regions in a map can be colored using four colors.
    • Topics1 GraphsIntroductionConnectivityPlanar GraphsSearching Graphs2 TreesIntroductionRooted TreesBinary TreesDecision Trees3 Weighted GraphsIntroductionShortest PathMinimum Spanning Tree
    • Searching Graphssearching nodes of graph G = (V , E) starting from node v1depth-firstbreadth-first
    • Depth-First Search1 v ← v1, T = ∅, D = {v1}2 find smallest i in 2 ≤ i ≤ |V | such that (v, vi ) ∈ E and vi /∈ Dif no such i exists: go to step 3if found: T = T ∪ {(v, vi )}, D = D ∪ {vi }, v ← vi ,go to step 23 if v = v1 then the result is T4 if v = v1 then v ← parent(v), go to step 2
    • Depth-First Search1 v ← v1, T = ∅, D = {v1}2 find smallest i in 2 ≤ i ≤ |V | such that (v, vi ) ∈ E and vi /∈ Dif no such i exists: go to step 3if found: T = T ∪ {(v, vi )}, D = D ∪ {vi }, v ← vi ,go to step 23 if v = v1 then the result is T4 if v = v1 then v ← parent(v), go to step 2
    • Depth-First Search1 v ← v1, T = ∅, D = {v1}2 find smallest i in 2 ≤ i ≤ |V | such that (v, vi ) ∈ E and vi /∈ Dif no such i exists: go to step 3if found: T = T ∪ {(v, vi )}, D = D ∪ {vi }, v ← vi ,go to step 23 if v = v1 then the result is T4 if v = v1 then v ← parent(v), go to step 2
    • Depth-First Search1 v ← v1, T = ∅, D = {v1}2 find smallest i in 2 ≤ i ≤ |V | such that (v, vi ) ∈ E and vi /∈ Dif no such i exists: go to step 3if found: T = T ∪ {(v, vi )}, D = D ∪ {vi }, v ← vi ,go to step 23 if v = v1 then the result is T4 if v = v1 then v ← parent(v), go to step 2
    • Breadth-First Search1 T = ∅, D = {v1}, Q = (v1)2 if Q is empty: the result is T3 if Q not empty: v ← front(Q), Q ← Q − vfor 2 ≤ i ≤ |V | check the edges (v, vi ) ∈ E:if vi /∈ D : Q = Q + vi , T = T ∪ {(v, vi )}, D = D ∪ {vi }go to step 3
    • Breadth-First Search1 T = ∅, D = {v1}, Q = (v1)2 if Q is empty: the result is T3 if Q not empty: v ← front(Q), Q ← Q − vfor 2 ≤ i ≤ |V | check the edges (v, vi ) ∈ E:if vi /∈ D : Q = Q + vi , T = T ∪ {(v, vi )}, D = D ∪ {vi }go to step 3
    • ReferencesRequired Reading: GrimaldiChapter 11: An Introduction to Graph TheoryChapter 7: Relations: The Second Time Around7.2. Computer Recognition: Zero-One Matricesand Directed Graphs
    • Topics1 GraphsIntroductionConnectivityPlanar GraphsSearching Graphs2 TreesIntroductionRooted TreesBinary TreesDecision Trees3 Weighted GraphsIntroductionShortest PathMinimum Spanning Tree
    • TreeDefinitiontree: a connected graph that contains no cycleforest: a graph where the connected components are trees
    • TreeDefinitiontree: a connected graph that contains no cycleforest: a graph where the connected components are trees
    • Tree ExamplesExample
    • Tree TheoremsTheoremIn a tree, there is one and only one pathbetween any two distinct nodes.there is at least one path because the tree is connectedif there were more than one path, they would form a cycle
    • Tree TheoremsTheoremLet T = (V , E) be a tree:|E| = |V | − 1proof method: induction on the number of edges
    • Tree TheoremsProof: base step|E| = 0 ⇒ |V | = 1|E| = 1 ⇒ |V | = 2|E| = 2 ⇒ |V | = 3assume that |E| = |V | − 1 for |E| ≤ k
    • Tree TheoremsProof: base step|E| = 0 ⇒ |V | = 1|E| = 1 ⇒ |V | = 2|E| = 2 ⇒ |V | = 3assume that |E| = |V | − 1 for |E| ≤ k
    • Tree TheoremsProof: induction step.|E| = k + 1let’s remove the edge (y, z):T1 = (V1, E1), T2 = (V2, E2)|V | = |V1| + |V2|= |E1| + 1 + |E2| + 1= (|E1| + |E2| + 1) + 1= |E| + 1
    • Tree TheoremsProof: induction step.|E| = k + 1let’s remove the edge (y, z):T1 = (V1, E1), T2 = (V2, E2)|V | = |V1| + |V2|= |E1| + 1 + |E2| + 1= (|E1| + |E2| + 1) + 1= |E| + 1
    • Tree TheoremsProof: induction step.|E| = k + 1let’s remove the edge (y, z):T1 = (V1, E1), T2 = (V2, E2)|V | = |V1| + |V2|= |E1| + 1 + |E2| + 1= (|E1| + |E2| + 1) + 1= |E| + 1
    • Tree TheoremsProof: induction step.|E| = k + 1let’s remove the edge (y, z):T1 = (V1, E1), T2 = (V2, E2)|V | = |V1| + |V2|= |E1| + 1 + |E2| + 1= (|E1| + |E2| + 1) + 1= |E| + 1
    • Tree TheoremsProof: induction step.|E| = k + 1let’s remove the edge (y, z):T1 = (V1, E1), T2 = (V2, E2)|V | = |V1| + |V2|= |E1| + 1 + |E2| + 1= (|E1| + |E2| + 1) + 1= |E| + 1
    • Tree TheoremsProof: induction step.|E| = k + 1let’s remove the edge (y, z):T1 = (V1, E1), T2 = (V2, E2)|V | = |V1| + |V2|= |E1| + 1 + |E2| + 1= (|E1| + |E2| + 1) + 1= |E| + 1
    • Tree TheoremsTheoremIn a tree, there are at least two nodes with degree 1.Proof.2|E| = v∈V dvassume that there is only 1 node with degree 1:⇒ 2|E| ≥ 2(|V | − 1) + 1⇒ 2|E| ≥ 2|V | − 1⇒ |E| ≥ |V | − 12 > |V | − 1
    • Tree TheoremsTheoremIn a tree, there are at least two nodes with degree 1.Proof.2|E| = v∈V dvassume that there is only 1 node with degree 1:⇒ 2|E| ≥ 2(|V | − 1) + 1⇒ 2|E| ≥ 2|V | − 1⇒ |E| ≥ |V | − 12 > |V | − 1
    • Tree TheoremsTheoremIn a tree, there are at least two nodes with degree 1.Proof.2|E| = v∈V dvassume that there is only 1 node with degree 1:⇒ 2|E| ≥ 2(|V | − 1) + 1⇒ 2|E| ≥ 2|V | − 1⇒ |E| ≥ |V | − 12 > |V | − 1
    • Tree TheoremsTheoremIn a tree, there are at least two nodes with degree 1.Proof.2|E| = v∈V dvassume that there is only 1 node with degree 1:⇒ 2|E| ≥ 2(|V | − 1) + 1⇒ 2|E| ≥ 2|V | − 1⇒ |E| ≥ |V | − 12 > |V | − 1
    • Tree TheoremsTheoremIn a tree, there are at least two nodes with degree 1.Proof.2|E| = v∈V dvassume that there is only 1 node with degree 1:⇒ 2|E| ≥ 2(|V | − 1) + 1⇒ 2|E| ≥ 2|V | − 1⇒ |E| ≥ |V | − 12 > |V | − 1
    • Tree TheoremsTheoremIn a tree, there are at least two nodes with degree 1.Proof.2|E| = v∈V dvassume that there is only 1 node with degree 1:⇒ 2|E| ≥ 2(|V | − 1) + 1⇒ 2|E| ≥ 2|V | − 1⇒ |E| ≥ |V | − 12 > |V | − 1
    • Tree TheoremsTheoremIn a tree, there are at least two nodes with degree 1.Proof.2|E| = v∈V dvassume that there is only 1 node with degree 1:⇒ 2|E| ≥ 2(|V | − 1) + 1⇒ 2|E| ≥ 2|V | − 1⇒ |E| ≥ |V | − 12 > |V | − 1
    • Tree TheoremsTheoremT is a tree (T is connected and contains no cycle).⇔There is one and only one pathbetween any two distinct nodes in T.⇔T is connected, but if any edge is removedit will no longer be connected.⇔T contains no cycle, but if an edge is addedbetween any pair of nodes one and only one cycle will be formed.
    • Tree TheoremsTheoremT is a tree (T is connected and contains no cycle).⇔T is connected and |E| = |V | − 1.⇔T contains no cycle and |E| = |V | − 1.
    • Topics1 GraphsIntroductionConnectivityPlanar GraphsSearching Graphs2 TreesIntroductionRooted TreesBinary TreesDecision Trees3 Weighted GraphsIntroductionShortest PathMinimum Spanning Tree
    • Rooted Treea hierarchy is defined between nodeshierarchy creates a natural direction on edges⇒ in and out degreesnode with in-degree 0 (top of the hierarchy): rootnodes with out-degree 0: leafnodes that are not leaves: internal node
    • Rooted Treea hierarchy is defined between nodeshierarchy creates a natural direction on edges⇒ in and out degreesnode with in-degree 0 (top of the hierarchy): rootnodes with out-degree 0: leafnodes that are not leaves: internal node
    • Node LevelDefinitionlevel of a node: the distance of the node from the rootparent: adjacent node in the next upper levelchildren: adjacent nodes in the next lower levelsibling: nodes which have the same parent
    • Rooted Tree ExampleExampleroot: rleaves: x y z u vinternal nodes: r p n t s q wparent of y: wchildren of w: y and zy and z are siblings
    • Rooted Tree ExampleExampleBookC1S1.1S1.2C2C3S3.1S3.2S3.2.1S3.2.2S3.3
    • Ordered Rooted Treesibling nodes are ordered from left to rightuniversal address systemassign the address 0 to the rootassign the positive integers 1, 2, 3, . . . to the nodes at level 1,from left to rightlet v be an internal node with address a,assign the addresses a.1, a.2, a.3, . . . to the children of vfrom left to right
    • Lexicographic OrderDefinitionLet b and c be two addresses.b comes before c if one of the following holds:1 b = a1a2 . . . amx1 . . .c = a1a2 . . . amx2 . . .x1 comes before x22 b = a1a2 . . . amc = a1a2 . . . amam+1 . . .
    • Lexicographic OrderDefinitionLet b and c be two addresses.b comes before c if one of the following holds:1 b = a1a2 . . . amx1 . . .c = a1a2 . . . amx2 . . .x1 comes before x22 b = a1a2 . . . amc = a1a2 . . . amam+1 . . .
    • Lexicographic Order ExampleExample0 - 1 - 1.1 - 1.2- 1.2.1 - 1.2.2 - 1.2.3- 1.2.3.1 - 1.2.3.2- 1.3 - 1.4 - 2- 2.1 - 2.2 - 2.2.1- 3 - 3.1 - 3.2
    • Topics1 GraphsIntroductionConnectivityPlanar GraphsSearching Graphs2 TreesIntroductionRooted TreesBinary TreesDecision Trees3 Weighted GraphsIntroductionShortest PathMinimum Spanning Tree
    • Binary TreesDefinitionT = (V , E) is a binary tree: ∀v ∈ V dvo∈ {0, 1, 2}T = (V , E) is a complete binary tree: ∀v ∈ V dvo∈ {0, 2}
    • Expression Treea binary operation can be represented as a binary treeoperator as the root, operands as the childrenevery mathematical expression can be represented as a treeoperators at internal nodes, variables and values at the leaves
    • Expression Tree ExamplesExample (7 − a) Example (a + b)
    • Expression Tree ExamplesExample ((7 − a)/5) Example ((a + b) ↑ 3)
    • Expression Tree ExamplesExample (((7 − a)/5) ∗ ((a + b) ↑ 3))
    • Expression Tree ExamplesExample (t + (u ∗ v)/(w + x − y ↑ z))
    • Expression Tree Traversals1 inorder traversal: traverse the left subtree, visit the root,traverse the right subtree2 preorder traversal: visit the root, traverse the left subtree,traverse the right subtree3 postorder traversal: traverse the left subtree,traverse the right subtree, visit the rootreverse Polish notation
    • Inorder Traversal ExampleExamplet + u ∗ v / w + x − y ↑ z
    • Preorder Traversal ExampleExample+ t / ∗ u v + w − x ↑ y z
    • Postorder Traversal ExampleExamplet u v ∗ w x y z ↑ − + / +
    • Expression Tree Evaluationinorder traversal requires parantheses for precedencepreorder and postorder traversals do not require parantheses
    • Postorder Evaluation ExampleExample (t u v ∗ w x y z ↑ − + / +)4 2 3 ∗ 1 9 2 3 ↑ − + / +4 2 3 ∗4 6 1 9 2 3 ↑4 6 1 9 8 −4 6 1 1 +4 6 2 /4 3 +7
    • Postorder Evaluation ExampleExample (t u v ∗ w x y z ↑ − + / +)4 2 3 ∗ 1 9 2 3 ↑ − + / +4 2 3 ∗4 6 1 9 2 3 ↑4 6 1 9 8 −4 6 1 1 +4 6 2 /4 3 +7
    • Postorder Evaluation ExampleExample (t u v ∗ w x y z ↑ − + / +)4 2 3 ∗ 1 9 2 3 ↑ − + / +4 2 3 ∗4 6 1 9 2 3 ↑4 6 1 9 8 −4 6 1 1 +4 6 2 /4 3 +7
    • Postorder Evaluation ExampleExample (t u v ∗ w x y z ↑ − + / +)4 2 3 ∗ 1 9 2 3 ↑ − + / +4 2 3 ∗4 6 1 9 2 3 ↑4 6 1 9 8 −4 6 1 1 +4 6 2 /4 3 +7
    • Postorder Evaluation ExampleExample (t u v ∗ w x y z ↑ − + / +)4 2 3 ∗ 1 9 2 3 ↑ − + / +4 2 3 ∗4 6 1 9 2 3 ↑4 6 1 9 8 −4 6 1 1 +4 6 2 /4 3 +7
    • Postorder Evaluation ExampleExample (t u v ∗ w x y z ↑ − + / +)4 2 3 ∗ 1 9 2 3 ↑ − + / +4 2 3 ∗4 6 1 9 2 3 ↑4 6 1 9 8 −4 6 1 1 +4 6 2 /4 3 +7
    • Postorder Evaluation ExampleExample (t u v ∗ w x y z ↑ − + / +)4 2 3 ∗ 1 9 2 3 ↑ − + / +4 2 3 ∗4 6 1 9 2 3 ↑4 6 1 9 8 −4 6 1 1 +4 6 2 /4 3 +7
    • Postorder Evaluation ExampleExample (t u v ∗ w x y z ↑ − + / +)4 2 3 ∗ 1 9 2 3 ↑ − + / +4 2 3 ∗4 6 1 9 2 3 ↑4 6 1 9 8 −4 6 1 1 +4 6 2 /4 3 +7
    • Postorder Evaluation ExampleExample (t u v ∗ w x y z ↑ − + / +)4 2 3 ∗ 1 9 2 3 ↑ − + / +4 2 3 ∗4 6 1 9 2 3 ↑4 6 1 9 8 −4 6 1 1 +4 6 2 /4 3 +7
    • Postorder Evaluation ExampleExample (t u v ∗ w x y z ↑ − + / +)4 2 3 ∗ 1 9 2 3 ↑ − + / +4 2 3 ∗4 6 1 9 2 3 ↑4 6 1 9 8 −4 6 1 1 +4 6 2 /4 3 +7
    • Postorder Evaluation ExampleExample (t u v ∗ w x y z ↑ − + / +)4 2 3 ∗ 1 9 2 3 ↑ − + / +4 2 3 ∗4 6 1 9 2 3 ↑4 6 1 9 8 −4 6 1 1 +4 6 2 /4 3 +7
    • Postorder Evaluation ExampleExample (t u v ∗ w x y z ↑ − + / +)4 2 3 ∗ 1 9 2 3 ↑ − + / +4 2 3 ∗4 6 1 9 2 3 ↑4 6 1 9 8 −4 6 1 1 +4 6 2 /4 3 +7
    • Postorder Evaluation ExampleExample (t u v ∗ w x y z ↑ − + / +)4 2 3 ∗ 1 9 2 3 ↑ − + / +4 2 3 ∗4 6 1 9 2 3 ↑4 6 1 9 8 −4 6 1 1 +4 6 2 /4 3 +7
    • Postorder Evaluation ExampleExample (t u v ∗ w x y z ↑ − + / +)4 2 3 ∗ 1 9 2 3 ↑ − + / +4 2 3 ∗4 6 1 9 2 3 ↑4 6 1 9 8 −4 6 1 1 +4 6 2 /4 3 +7
    • Regular TreeDefinitionT = (V , E) is an m-ary tree: ∀v ∈ V dvo≤ mT = (V , E) is a complete m-ary tree: ∀v ∈ V dvo∈ {0, m}
    • Regular Tree TheoremTheoremLet T = (V , E) be a complete m-ary tree.n: number of nodesl: number of leavesi: number of internal nodesThen:n = m · i + 1l = n − i = m · i + 1 − i = (m − 1) · i + 1i =l − 1m − 1
    • Regular Tree TheoremTheoremLet T = (V , E) be a complete m-ary tree.n: number of nodesl: number of leavesi: number of internal nodesThen:n = m · i + 1l = n − i = m · i + 1 − i = (m − 1) · i + 1i =l − 1m − 1
    • Regular Tree TheoremTheoremLet T = (V , E) be a complete m-ary tree.n: number of nodesl: number of leavesi: number of internal nodesThen:n = m · i + 1l = n − i = m · i + 1 − i = (m − 1) · i + 1i =l − 1m − 1
    • Regular Tree TheoremTheoremLet T = (V , E) be a complete m-ary tree.n: number of nodesl: number of leavesi: number of internal nodesThen:n = m · i + 1l = n − i = m · i + 1 − i = (m − 1) · i + 1i =l − 1m − 1
    • Regular Tree TheoremTheoremLet T = (V , E) be a complete m-ary tree.n: number of nodesl: number of leavesi: number of internal nodesThen:n = m · i + 1l = n − i = m · i + 1 − i = (m − 1) · i + 1i =l − 1m − 1
    • Regular Tree TheoremTheoremLet T = (V , E) be a complete m-ary tree.n: number of nodesl: number of leavesi: number of internal nodesThen:n = m · i + 1l = n − i = m · i + 1 − i = (m − 1) · i + 1i =l − 1m − 1
    • Regular Tree ExamplesExamplehow many matches are played in a tennis tournamentwith 27 players?every player is a leaf: l = 27every match is an internal node: m = 2number of matches: i = l−1m−1 = 27−12−1 = 26
    • Regular Tree ExamplesExamplehow many matches are played in a tennis tournamentwith 27 players?every player is a leaf: l = 27every match is an internal node: m = 2number of matches: i = l−1m−1 = 27−12−1 = 26
    • Regular Tree ExamplesExamplehow many extension cords with 4 outlets are requiredto connect 25 computers to a wall socket?every computer is a leaf: l = 25every extension cord is an internal node: m = 4number of cords: i = l−1m−1 = 25−14−1 = 8
    • Regular Tree ExamplesExamplehow many extension cords with 4 outlets are requiredto connect 25 computers to a wall socket?every computer is a leaf: l = 25every extension cord is an internal node: m = 4number of cords: i = l−1m−1 = 25−14−1 = 8
    • Topics1 GraphsIntroductionConnectivityPlanar GraphsSearching Graphs2 TreesIntroductionRooted TreesBinary TreesDecision Trees3 Weighted GraphsIntroductionShortest PathMinimum Spanning Tree
    • Decision TreesExampleone of 8 coins is counterfeit (it’s heavier)find the counterfeit coin using a beam balance
    • Decision TreesExample (in 3 weighings)
    • Decision TreesExample (in 2 weighings)
    • ReferencesRequired Reading: GrimaldiChapter 12: Trees12.1. Definitions and Examples12.2. Rooted Trees
    • Topics1 GraphsIntroductionConnectivityPlanar GraphsSearching Graphs2 TreesIntroductionRooted TreesBinary TreesDecision Trees3 Weighted GraphsIntroductionShortest PathMinimum Spanning Tree
    • Weighted Graphsassign labels to edges:weight, length, cost, delay, probability, . . .
    • Topics1 GraphsIntroductionConnectivityPlanar GraphsSearching Graphs2 TreesIntroductionRooted TreesBinary TreesDecision Trees3 Weighted GraphsIntroductionShortest PathMinimum Spanning Tree
    • Shortest Pathfind the shortest paths from a node to all other nodes:Dijkstra’s algorithm
    • Dijkstra’s Algorithm ExampleExample (initialization)starting node: ca (∞, −)b (∞, −)c (0, −)f (∞, −)g (∞, −)h (∞, −)
    • Dijkstra’s Algorithm ExampleExample (from node c - base distance=0)c → f : 6, 6 < ∞c → h : 11, 11 < ∞a (∞, −)b (∞, −)c (0, −)√f (6, cf )g (∞, −)h (11, ch)closest node: f
    • Dijkstra’s Algorithm ExampleExample (from node c - base distance=0)c → f : 6, 6 < ∞c → h : 11, 11 < ∞a (∞, −)b (∞, −)c (0, −)√f (6, cf )g (∞, −)h (11, ch)closest node: f
    • Dijkstra’s Algorithm ExampleExample (from node c - base distance=0)c → f : 6, 6 < ∞c → h : 11, 11 < ∞a (∞, −)b (∞, −)c (0, −)√f (6, cf )g (∞, −)h (11, ch)closest node: f
    • Dijkstra’s Algorithm ExampleExample (from node f - base distance=6)f → a : 6 + 11, 17 < ∞f → g : 6 + 9, 15 < ∞f → h : 6 + 4, 10 < 11a (17, cfa)b (∞, −)c (0, −)√f (6, cf )√g (15, cfg)h (10, cfh)closest node: h
    • Dijkstra’s Algorithm ExampleExample (from node f - base distance=6)f → a : 6 + 11, 17 < ∞f → g : 6 + 9, 15 < ∞f → h : 6 + 4, 10 < 11a (17, cfa)b (∞, −)c (0, −)√f (6, cf )√g (15, cfg)h (10, cfh)closest node: h
    • Dijkstra’s Algorithm ExampleExample (from node f - base distance=6)f → a : 6 + 11, 17 < ∞f → g : 6 + 9, 15 < ∞f → h : 6 + 4, 10 < 11a (17, cfa)b (∞, −)c (0, −)√f (6, cf )√g (15, cfg)h (10, cfh)closest node: h
    • Dijkstra’s Algorithm ExampleExample (from node h - base distance=10)h → a : 10 + 11, 21 17h → g : 10 + 4, 14 < 15a (17, cfa)b (∞, −)c (0, −)√f (6, cf )√g (14, cfhg)h (10, cfh)√closest node: g
    • Dijkstra’s Algorithm ExampleExample (from node h - base distance=10)h → a : 10 + 11, 21 17h → g : 10 + 4, 14 < 15a (17, cfa)b (∞, −)c (0, −)√f (6, cf )√g (14, cfhg)h (10, cfh)√closest node: g
    • Dijkstra’s Algorithm ExampleExample (from node h - base distance=10)h → a : 10 + 11, 21 17h → g : 10 + 4, 14 < 15a (17, cfa)b (∞, −)c (0, −)√f (6, cf )√g (14, cfhg)h (10, cfh)√closest node: g
    • Dijkstra’s Algorithm ExampleExample (from node g - base distance=14)g → a : 14 + 17, 31 17a (17, cfa)b (∞, −)c (0, −)√f (6, cf )√g (14, cfhg)√h (10, cfh)√closest node: a
    • Dijkstra’s Algorithm ExampleExample (from node g - base distance=14)g → a : 14 + 17, 31 17a (17, cfa)b (∞, −)c (0, −)√f (6, cf )√g (14, cfhg)√h (10, cfh)√closest node: a
    • Dijkstra’s Algorithm ExampleExample (from node g - base distance=14)g → a : 14 + 17, 31 17a (17, cfa)b (∞, −)c (0, −)√f (6, cf )√g (14, cfhg)√h (10, cfh)√closest node: a
    • Dijkstra’s Algorithm ExampleExample (from node a - base distance=17)a → b : 17 + 5, 22 < ∞a (17, cfa)√b (22, cfab)c (0, −)√f (6, cf )√g (14, cfhg)√h (10, cfh)√last node: b
    • Dijkstra’s Algorithm ExampleExample (from node a - base distance=17)a → b : 17 + 5, 22 < ∞a (17, cfa)√b (22, cfab)c (0, −)√f (6, cf )√g (14, cfhg)√h (10, cfh)√last node: b
    • Dijkstra’s Algorithm ExampleExample (from node a - base distance=17)a → b : 17 + 5, 22 < ∞a (17, cfa)√b (22, cfab)c (0, −)√f (6, cf )√g (14, cfhg)√h (10, cfh)√last node: b
    • Topics1 GraphsIntroductionConnectivityPlanar GraphsSearching Graphs2 TreesIntroductionRooted TreesBinary TreesDecision Trees3 Weighted GraphsIntroductionShortest PathMinimum Spanning Tree
    • Spanning TreeDefinitionspanning tree:a subgraph which is a tree and contains all the nodes of the graphDefinitionminimum spanning tree:a spanning tree for which the total weight of edges is minimal
    • Spanning TreeDefinitionspanning tree:a subgraph which is a tree and contains all the nodes of the graphDefinitionminimum spanning tree:a spanning tree for which the total weight of edges is minimal
    • Kruskal’s AlgorithmKruskal’s algorithm1 i ← 1, e1 ∈ E, wt(e1) is minimal2 for 1 ≤ i ≤ n − 2:the selected edges are e1, e2, . . . , eiselect a new edge ei+1 from the remaining edges such that:wt(ei+1) is minimale1, e2, . . . , ei , ei+1 contains no cycle3 i ← i + 1i = n − 1 ⇒ the subgraph G containing the edgese1, e2, . . . , en−1 is a minimum spanning treei < n − 1 ⇒ go to step 2
    • Kruskal’s AlgorithmKruskal’s algorithm1 i ← 1, e1 ∈ E, wt(e1) is minimal2 for 1 ≤ i ≤ n − 2:the selected edges are e1, e2, . . . , eiselect a new edge ei+1 from the remaining edges such that:wt(ei+1) is minimale1, e2, . . . , ei , ei+1 contains no cycle3 i ← i + 1i = n − 1 ⇒ the subgraph G containing the edgese1, e2, . . . , en−1 is a minimum spanning treei < n − 1 ⇒ go to step 2
    • Kruskal’s AlgorithmKruskal’s algorithm1 i ← 1, e1 ∈ E, wt(e1) is minimal2 for 1 ≤ i ≤ n − 2:the selected edges are e1, e2, . . . , eiselect a new edge ei+1 from the remaining edges such that:wt(ei+1) is minimale1, e2, . . . , ei , ei+1 contains no cycle3 i ← i + 1i = n − 1 ⇒ the subgraph G containing the edgese1, e2, . . . , en−1 is a minimum spanning treei < n − 1 ⇒ go to step 2
    • Kruskal’s Algorithm ExampleExample (initialization)i ← 1minimum weight: 1(e, g)T = {(e, g)}
    • Kruskal’s Algorithm ExampleExample (initialization)i ← 1minimum weight: 1(e, g)T = {(e, g)}
    • Kruskal’s Algorithm ExampleExample (initialization)i ← 1minimum weight: 1(e, g)T = {(e, g)}
    • Kruskal’s Algorithm ExampleExample (1 < 6)minimum weight: 2(d, e), (d, f ), (f , g)T = {(e, g), (d, f )}i ← 2
    • Kruskal’s Algorithm ExampleExample (1 < 6)minimum weight: 2(d, e), (d, f ), (f , g)T = {(e, g), (d, f )}i ← 2
    • Kruskal’s Algorithm ExampleExample (1 < 6)minimum weight: 2(d, e), (d, f ), (f , g)T = {(e, g), (d, f )}i ← 2
    • Kruskal’s Algorithm ExampleExample (2 < 6)minimum weight: 2(d, e), (f , g)T = {(e, g), (d, f ), (d, e)}i ← 3
    • Kruskal’s Algorithm ExampleExample (2 < 6)minimum weight: 2(d, e), (f , g)T = {(e, g), (d, f ), (d, e)}i ← 3
    • Kruskal’s Algorithm ExampleExample (2 < 6)minimum weight: 2(d, e), (f , g)T = {(e, g), (d, f ), (d, e)}i ← 3
    • Kruskal’s Algorithm ExampleExample (3 < 6)minimum weight: 2(f , g) forms a cycleminimum weight: 3(c, e), (c, g), (d, g)(d, g) forms a cycleT = {(e, g), (d, f ), (d, e), (c, e)}i ← 4
    • Kruskal’s Algorithm ExampleExample (3 < 6)minimum weight: 2(f , g) forms a cycleminimum weight: 3(c, e), (c, g), (d, g)(d, g) forms a cycleT = {(e, g), (d, f ), (d, e), (c, e)}i ← 4
    • Kruskal’s Algorithm ExampleExample (3 < 6)minimum weight: 2(f , g) forms a cycleminimum weight: 3(c, e), (c, g), (d, g)(d, g) forms a cycleT = {(e, g), (d, f ), (d, e), (c, e)}i ← 4
    • Kruskal’s Algorithm ExampleExample (3 < 6)minimum weight: 2(f , g) forms a cycleminimum weight: 3(c, e), (c, g), (d, g)(d, g) forms a cycleT = {(e, g), (d, f ), (d, e), (c, e)}i ← 4
    • Kruskal’s Algorithm ExampleExample (4 < 6)T = {(e, g), (d, f ), (d, e),(c, e), (b, e)}i ← 5
    • Kruskal’s Algorithm ExampleExample (4 < 6)T = {(e, g), (d, f ), (d, e),(c, e), (b, e)}i ← 5
    • Kruskal’s Algorithm ExampleExample (5 < 6)T = {(e, g), (d, f ), (d, e),(c, e), (b, e), (a, b)}i ← 6
    • Kruskal’s Algorithm ExampleExample (5 < 6)T = {(e, g), (d, f ), (d, e),(c, e), (b, e), (a, b)}i ← 6
    • Kruskal’s Algorithm ExampleExample (6 6)total weight: 17
    • Prim’s AlgorithmPrim’s algorithm1 i ← 1, v1 ∈ V , P = {v1}, N = V − {v1}, T = ∅2 for 1 ≤ i ≤ n − 1:P = {v1, v2, . . . , vi }, T = {e1, e2, . . . , ei−1}, N = V − Pselect a node vi+1 ∈ N such that for a node x ∈ Pe = (x, vi+1) /∈ T, wt(e) is minimalP ← P + {vi+1}, N ← N − {vi+1}, T ← T + {e}3 i ← i + 1i = n ⇒: the subgraph G containing the edgese1, e2, . . . , en−1 is a minimum spanning treei < n ⇒ go to step 2
    • Prim’s AlgorithmPrim’s algorithm1 i ← 1, v1 ∈ V , P = {v1}, N = V − {v1}, T = ∅2 for 1 ≤ i ≤ n − 1:P = {v1, v2, . . . , vi }, T = {e1, e2, . . . , ei−1}, N = V − Pselect a node vi+1 ∈ N such that for a node x ∈ Pe = (x, vi+1) /∈ T, wt(e) is minimalP ← P + {vi+1}, N ← N − {vi+1}, T ← T + {e}3 i ← i + 1i = n ⇒: the subgraph G containing the edgese1, e2, . . . , en−1 is a minimum spanning treei < n ⇒ go to step 2
    • Prim’s AlgorithmPrim’s algorithm1 i ← 1, v1 ∈ V , P = {v1}, N = V − {v1}, T = ∅2 for 1 ≤ i ≤ n − 1:P = {v1, v2, . . . , vi }, T = {e1, e2, . . . , ei−1}, N = V − Pselect a node vi+1 ∈ N such that for a node x ∈ Pe = (x, vi+1) /∈ T, wt(e) is minimalP ← P + {vi+1}, N ← N − {vi+1}, T ← T + {e}3 i ← i + 1i = n ⇒: the subgraph G containing the edgese1, e2, . . . , en−1 is a minimum spanning treei < n ⇒ go to step 2
    • Prim’s Algorithm ExampleExample (initialization)i ← 1P = {a}N = {b, c, d, e, f , g}T = ∅
    • Prim’s Algorithm ExampleExample (initialization)i ← 1P = {a}N = {b, c, d, e, f , g}T = ∅
    • Prim’s Algorithm ExampleExample (1 < 7)T = {(a, b)}P = {a, b}N = {c, d, e, f , g}i ← 2
    • Prim’s Algorithm ExampleExample (1 < 7)T = {(a, b)}P = {a, b}N = {c, d, e, f , g}i ← 2
    • Prim’s Algorithm ExampleExample (2 < 7)T = {(a, b), (b, e)}P = {a, b, e}N = {c, d, f , g}i ← 3
    • Prim’s Algorithm ExampleExample (2 < 7)T = {(a, b), (b, e)}P = {a, b, e}N = {c, d, f , g}i ← 3
    • Prim’s Algorithm ExampleExample (3 < 7)T = {(a, b), (b, e), (e, g)}P = {a, b, e, g}N = {c, d, f }i ← 4
    • Prim’s Algorithm ExampleExample (3 < 7)T = {(a, b), (b, e), (e, g)}P = {a, b, e, g}N = {c, d, f }i ← 4
    • Prim’s Algorithm ExampleExample (4 < 7)T = {(a, b), (b, e), (e, g), (d, e)}P = {a, b, e, g, d}N = {c, f }i ← 5
    • Prim’s Algorithm ExampleExample (4 < 7)T = {(a, b), (b, e), (e, g), (d, e)}P = {a, b, e, g, d}N = {c, f }i ← 5
    • Prim’s Algorithm ExampleExample (5 < 7)T = {(a, b), (b, e), (e, g),(d, e), (f , g)}P = {a, b, e, g, d, f }N = {c}i ← 6
    • Prim’s Algorithm ExampleExample (5 < 7)T = {(a, b), (b, e), (e, g),(d, e), (f , g)}P = {a, b, e, g, d, f }N = {c}i ← 6
    • Prim’s Algorithm ExampleExample (6 < 7)T = {(a, b), (b, e), (e, g),(d, e), (f , g), (c, g)}P = {a, b, e, g, d, f , c}N = ∅i ← 7
    • Prim’s Algorithm ExampleExample (6 < 7)T = {(a, b), (b, e), (e, g),(d, e), (f , g), (c, g)}P = {a, b, e, g, d, f , c}N = ∅i ← 7
    • Prim’s Algorithm ExampleExample (7 7)total weight: 17
    • ReferencesRequired Reading: GrimaldiChapter 13: Optimization and Matching13.1. Dijkstra’s Shortest Path Algorithm13.2. Minimal Spanning Trees:The Algorithms of Kruskal and Prim