COMP 2711H: Lecture 12

Date: 2024-09-30 09:04:41

Reviewed:

Topic / Chapter:

summary

❓Questions

Notes

Graph Theory
  • Graph Theory

    • πŸ‘¨β€πŸ« geometry: doesn't matter:
      • only thing matters: whether edge / path from point to exists
      • e.g. can send message to ?
    • graph :
      • tuple of vertices & edge
      • : set of vertices
        • mostly: are finite (sometimes not)
      • : a finite set of edges
        • every : of form
    • two graphs with same : equivalent
      • i.e. we on't care about
    • loop: an edge
      • i.e. edge where start = end
      • πŸ‘¨β€πŸ« stupid idea if you think of it as computer network
    • simple graph: graph without loop
    • if : : neighbors / adjacent
    • complete graph: when every element is neighbor of every other one
      • complement: empty graph
      • : complete graph on vertices
    • complement:
---
        title: G
        ---
        graph LR
        1((1))
        2((2))
        3((3))
        4((4))
        1<-->2
        1<-->3
        1<--/-->4
        2<-->3
        2<--/-->4
        3<-->4
---
        title: G'
        ---
        graph LR
        1((1))
        2((2))
        3((3))
        4((4))
        1<--/-->2
        1<--/-->3
        1<-->4
        2<--/-->3
        2<-->4
        3<--/-->4
  • : has vertices
  • : subgraph of if:
  • Isomorphism

    • labels on vertices: somewhat meaningless
      • πŸ‘¨β€πŸŽ“ : as they are just names
    • isomorphism: when you can re-label one graph to show another
    • rigorously: for ,
      • isomorphism:
        • s.t. : one-to-one & onto
    • degree of :
      • i.e. count of neighbors
      • if : is isolated verted
    • theorem:
      • basically: the idea of shake-hands
    • say, we add edges from
      • when you add ,
    • adjacent matrix
      • matrix where
      • for simple graph: all
        • as no loop exists
    • if: we want to find all neighbors-of-neighbors:
      • can be given by:
      • πŸ‘¨β€πŸ« can be further expanded to multiple networks
        • will be used more often in 3711
    • walk: seq. of vertices & edges
      • s.t. every
      • for simple graph: it doesn't matter
        • πŸ‘¨β€πŸ« however, will be useful later
          • when there exists more than one edge between two vertices
    • trail: walk without repeated edges
    • path: work without repeated vertex
    • path βŠ† trail, but not the other way
---
    title: G
    ---
    graph LR
    1((1))
    2((2))
    3((3))
    4((4))
    5((5))
    1<-->2
    2<-->3
    1<-->3
    4<-->5
    5<-->3
    4<-->3
- then <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">β†’</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">β†’</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">β†’</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">4</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">β†’</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">β†’</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">β†’</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>: a trail but not a path
  • closed trail: when a trail begins & ends at the same edge
    • aka circuit
  • cycle: substitute of closed path
    • and no vertices other than repeats
    • and only appears in the beginning & end
  • theorem: every walk: contains a path:
    • weaker: if there is a walk , then also path
  • proof of weaker theorem:
    • consider: let : (one of) the shortest walk from
    • claim: is a path
      • if is not a path
      • => there exists repetition of vertex
      • however, then we can skip the cycle of , and go directly to
      • which, provides a shorter walk
        • contradiction
  • proof of stronger theorem:
    • can be proven w/ similar idea
  • KΓΆnigsberg bridges

    • exists a (multi) graph
graph LR
    1((1))
    2((2))
    3((3))
    4((4))
    1<-->2
    1<-->2
    1<-->3
    2<-->3
    2<-->4
    2<-->4
    3<-->4
  • is there a closed walk that goes through all edges exactly once?
  • solved by Euler: impossible
    • all the vertex: with odd number of degree
    • no vertex w/ even number of degree (essential for comming-back)
  • Connectivity

    • vertex connected to iff -path
      • not necessarily adjacent
    • a graph : connected if every pair of vertices are
    • πŸ‘¨β€πŸ« internet is a connected graph
      • not that they are connected in practice...
    • connected component (cc): a maximal connected subset of vertices
    • theorem: a graph with vertices and edges: has at least
      • camps
    • proof:
      • empty graph w/ component
      • adding an edge: decreases no. of cc at most by
    • corollary: every connected graph has
    • tree: connected graph with edges
    • theorem: following three are equivalent
      1. : connected and (is a tree)
      2. : connected and has no cycles
      3. and has no cycles
      • πŸ‘¨β€πŸ« like a triangle / triple iff
    • proof:
      • : start w/ empty graph; add edges
        • at least edges must be added to make it connected
        • every edge : reduced no. of cc
        • however, to be a cycle: there must be an edge within cc
          • i.e. not reducing no. of cc
      • :
        • you can't have more than edges without making a cycle
        • you can't have less than edges to make it connected
        • thus: it has exactly edges
      • thus
      • :
        • you can't have more than edges without making a cycle
        • you can't have less than edges to make it connected
        • thus: it has exactly edges (same)
      • :
        • you can't have more than edges without making a cycle
        • you can't have less than edges to make it connected
        • thus: it has exactly edges (same)
    • theorem: an edge : a cut iff
      • : not part of any cycle
      • πŸ‘¨β€πŸ« if you forget what is iff: it's logical error
        • ⚠️ leads to an F!!!
    • proof: assume : a cut
      • of
      • s.t. removal of will make two cc disconnected
      • suppose: in cycle
      • if there exists a cycle: there must exist another edge connected two cc
      • assume : there is an -path
        • if the path doesn't include : then removal of will not diconnect the components
        • if the path includes : it can still round its way through
    • proof: assume is not in any cycle: prove that is a cut
      • for it to not be a cut: there must exist , another path connecting components