ch10 discrete mathematics direct graph

Upload: ibrahim-khleifat

Post on 01-Jun-2018

261 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    1/84

    Discrete Mathematics & Mathematical Reasoning

    Chapter 10: Graphs

    Kousha Etessami

    U. of Edinburgh, UK

    Kousha Etessami (U of Edinburgh UK) Discrete Mathematics (Chapter 6) 1 / 13

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    2/84

    Kousha Etessami (U of Edinburgh UK) Discrete Mathematics (Chapter 6) 1 / 13

    Overview

    Graphs and Graph Models

    Graph Terminology and Special Types of Graphs

    Representations of Graphs, and Graph

    IsomorphismConnectivity

    Euler and Hamiltonian Paths

    Brief look at other topics like graph coloring

    Kousha Etessami (U of Edinburgh UK) Discrete Mathematics (Chapter 6) 2 / 13

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    3/84

    What is a Graph?

    Informally, agraphconsists of a non-empty set ofvertices(or nodes),and a setEofedgesthat connect (pairs of) nodes.

    But different types of graphs (undirected, directed, simple, multigraph,

    . . .) have different formal definitions, depending on what kinds of edges

    are allowed.

    This creates a lot of (often inconsistent) terminology.

    Before formalizing, lets see some examples....

    During this course, we focus almost exclusively on standard

    (undirected) graphsanddirected graphs,which are our first two examples.

    Kousha Etessami (U of Edinburgh UK) Discrete Mathematics (Chapter 6) 3 / 13

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    4/84

    A(simple undirected) graph:

    LA

    SF

    NY

    ED

    Onlyundirectededges;at most one edgebetween any pair of distinct

    nodes; andno loops(edges between a node and itself).

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 4 / 13

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    5/84

    Adirected graph (digraph)(with loops):

    LA

    SF

    NY

    ED

    Onlydirectededges;at most one directed edgefromany nodetoany

    node; andloops are allowed.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 5 / 13

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    6/84

    Asimple directed graph:

    LA

    SF

    NY

    ED

    Onlydirectededges;at most one directed edgefrom any node to any

    other node; andno loops allowed.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 6 / 13

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    7/84

    Anundirected multigraph:

    LA

    SF

    NY

    ED

    Onlyundirectededges; may containmultiple edgesbetween a pair of

    nodes; butno loops.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 7 / 13

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    8/84

    Anundirected pseudograph:

    LA

    SF

    NY

    ED

    Onlyundirectededges; may containmultiple edgesbetween a pair of

    nodes; andmay contain loops(even multiple loops on the same node).

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 8 / 13

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    9/84

    Adirected multigraph:

    LA

    SF

    NY

    ED

    Onlydirectededges; may containmultiple edgesfrom one node to

    another; butno loops allowed.

    Warning: this differs slightly from the Rosen book terminology. The

    books notion of directed multigraph would allow loops.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 9 / 13

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    10/84

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    11/84

    Graph Terminology Zoo (ridiculous)

    Type Edges Multi-Edges? Loops?

    1. (simple undirected) graph Undirected No No

    2. (undirected) multigraph Undirected Yes No

    3. (undirected) pseudograph Undirected Yes Yes

    4. directed graph Directed No Yes

    5. simple directed graph Directed No No

    6. directed multigraph Directed Yes No1

    7. directed pseudograph Directed Yes Yes

    8. mixed graph Both Yes Yes

    We will focus on the two most standard types:

    (1.) graphs (simple undirected), and(4.) directed graphs(also known asdigraphs).

    1differs from book.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 11 / 13

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    12/84

    Formal Defintion of Directed Graphs

    Adirected graph(digraph),G= (V, E), consists of a non-empty set,

    V, ofvertices(ornodes), and a setEV V ofdirected edges(orarcs). Each directed edge(u, v) Ehas astart(tail) vertexu, and a

    end(head) vertexv.Note: a directed graphG= (V, E)is simply a set Vtogether with abinary relationEonV.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 12 / 13

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    13/84

    Definition of (Undirected) Graphs

    For a setV, let[V]k denote the set ofk-element subsets ofV.(Equivalently,[V]k is the set of all k-combinationsof V.)

    A (simple,undirected)graph,G= (V, E), consists of a non-empty set

    V ofvertices(or nodes), and a setE[V]

    2

    of (undirected)edges.Every edge{u, v} Ehas two distinct vertices u=vasendpoints,and such verticesuandvare then said to beadjacentin the graphG.

    Note: the above definitions allow for infinite graphs, where |V|= .

    In this course we will focus on finite graphs.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 13 / 13

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    14/84

    Graph Models: Computer Networks

    network where we careabout the number of links:we use a multigraph.

    diagnostic self-links at datacenters: we use apseudograph.

    network with multiple one-waylinks we use a directed!multi"graph.

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    15/84

    Applications of Graphs#$%$&'()*NG *+ A G&A,)

    !labeled directed etc. ..."

    graph theory can be used in modelling of:

    +ocial networksCommunications networks

    *nformation networks

    +oftware design

    (ransportation networks

    iological networks

    ......

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    16/84

    Graph Models: +ocial Networks model social structures: relationships between people or

    groups.

    /ertices represent indi/iduals or organi0ations edgesrepresent relationships between them.

    1seful graph models of social networks include:

    friendship graphs- undirected graphs where twopeople are connected if they are friends !e.g. on2acebook"

    collaboration graphs- undirected graphs where two

    people are connected if they collaborate in a specificway

    influence graphs- directed graphs where there is anedge from one person to another if the first person caninfluence the second

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    17/84

    Graph Models: +ocial NetworksExample: A friendshipgraph: two people areconnected if they are2acebook friends.

    Example: An

    influence graph

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    18/84

    *nformation Networks

    *n a web graph web pages are representedby /ertices and links are represented by

    directededges.*n a citation network:&esearch papers are represented by /ertices.

    When paper A cites paper there is an edge

    from the /erte3 representing paper A to the/erte3 representing paper .

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    19/84

    (ransportationGraphs

    Graph models are e3tensi/ely used to studytransportation networks.

    Airline networks can be modeled using

    directed multigraphs where:airports are represented by /ertices

    each flight is represented by a directed edgefrom the /erte3 representing the departureairport to the /erte3 representing thedestination airport

    &oad networks modeled using graphs

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    20/84

    iological Applications

    Graph models are used e3tensi/ely in manyareas of the biological science.

    Niche overlap graphs model competition

    between species in an ecosystem:

    Example: nicheo/erlap graph for aforest ecosystem.

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    21/84

    Degree and neighborhood of a vertex

    Definition 3. (he degreeof a vertex v in aundirected graph is the number of edgesincident with it. (he degree of the /erte3 vis

    denoted by deg!v".

    Definition 3. (he neighborhood !neighbor set"of a vertex vin a undirected graph, denoted

    N(v)is the set of /ertices ad9acent to /.

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    22/84

    4egrees and Neighborhoods of%ertices

    Example: What are the degrees andneighborhoods of the /ertices in the graphs Gand H

    Solution: deg!a" ; 7 deg!b" ; N!b" ; =a, c, e, f > N!d" ; =c>.

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    23/84

    )andshaking (heorem

    THEOREM 1 (Handshain! "emma#: *fG;!%$" is a undirected graph with medgesthen:

    2m=vV deg(v)

    Proof:

    Each edge contributes twice to the degree count of allvertices. Hence, both the left-hand and right-hand sidesof this equation equal twice the number of edges. QED

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    24/84

    4egree of %ertices !continued"

    Theorem $%An undirected graph has an e/ennumber of /ertices of odd degree.

    Proof% ?et V5 be the /ertices of e/en degreeand V7 be the /ertices of odd degree in graph

    G; !V E" with medges. (hen

    must be

    e/en sincedeg!v" ise/en foreach v@V5

    e/en

    must be e/en because 7mise/en and the sum of degrees

    of /ertices of e/en degree ise/en.(hus since this is thesum of degrees of all /erticesof odd degree there must bean e/en number of them.

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    25/84

    )andshaking (heorem:$3amples

    Example: )ow many edges are there in agraph with 56 /ertices each ha/ing degree si3

    Solution: the sum of the degrees of the/ertices is 56 ; 6. (he handshaking

    theorem says 7m; 6.+o the number of edges is m; B6.

    Example: *f a graph has /ertices can each

    /erte3 ha/e degree BSolution: (his is not possible by thehandshaking thorem because the sum of thedegrees of the /ertices B ; 5 is odd.

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    26/84

    4irected Graphs

    Definition% (he indegreeof a vertex vdenoted deg!!v" is the number of edgesdirected into v. (he outdegreeof v denoteddeg"!v", is the number of edges directed out ofv. Note that a loop at a /erte3 contributes 5 to

    both in-degree and out-degree.Example% *n the graph Gwe ha/e

    deg!!a" ; 7 deg!!b" ; 7

    deg!!c" ; B deg!!d" ; 7deg!!e" ; B deg!!f" ; 6.

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    27/84

    4irected Graphs !continued"

    Theorem 3: ?et G # !V, E"be a directed graph.(hen:

    Proof: (he first sum counts the number ofoutgoing edges o/er all /ertices and the second

    sum counts the number of incoming edges o/erall /ertices. oth sums must be D$D.

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    28/84

    +pecial (ypes of Graphs: CompleteGraphs

    A complete graph on n vertices denoted by is the simple graph that contains e3actly oneedge between each pair of distinct /ertices.

    Kn

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    29/84

    +pecial (ypes of Graphs: Cycles

    A c$cle for nE B consists of n/ertices v5v7,% ,vn and edges =v5, v7>, =v7, vB>,% ,=vn5, vn>, =vn, v5>&

    CnCnCn

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    30/84

    +pecial (ypes of +imple

    Graphs: n-CubesAn ndimensional h$percube or ncube is agraph with /ertices representing all bitstrings of length n where there is an edge

    between two /ertices if and only if they differ ine3actly one bit position.

    2n

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    31/84

    ipartite Graphs

    Definition%

    An eFui/alent definition of a bipartite graph isone where it is possible to colorthe /erticeseither red or blue so that no two ad9acent/ertices are the same color.

    Gisbipartite

    His notbipartite: if wecolor aredthen itsneighbors fandbmust be blue.ut f and b aread9acent.

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    32/84

    ipartite Graphs !continued"

    Example: +how that is bipartite.Solution: ,artition the /erte3 set into V5 ;=v5 vB v> and V7 ; =v7 v:

    Example: +how that ' is not bipartite.

    Solution: *f we partition /ertices of 'B into

    two nonempty sets one set must contain two/ertices. ut e/ery /erte3 is connected to e/eryother. +o the two /ertices in the same partitionare connected. )ence 'B is not bipartite.

    C6

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    33/84

    Complete ipartite Graphs

    Definition% A complete bipartite graphis a graph that has its /erte3 set partitionedinto two subsets V5 of si0e mand V7 of si0e nsuch that there is an edge from e/ery /erte3 in

    V5 to e/ery /erte3 in V7&

    Examples%

    Km,n

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    34/84

    +ubgraphs

    Definition% A subgraphof a graph G;!VE" is a graph !*+" where

    and . A subgraph Hof Gis a propersubgraphof Gif H G&Example: here is and one of its !proper"subgraphs:

    WV

    FEFE

    K5

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    35/84

    *nduced +ubgraphs

    Definition%?et G; !V E" be a graph. (hesubgraph induced by a subset * of the /erte3

    set Vis the graph ); !*+" whose edge

    set + contains an edge in E if and only if bothendpoints are in *&

    Example: )ere is - and itsinduced

    subgraphinduced by *; =a,b,c,e>.

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    36/84

    ipartite Graphs and Matchings

    ipartite graphs used e3tensi/ely in apps

    in/ol/ing matching elements of two sets:.ob assignments- /ertices represent the 9obsand the employees edges link employees with9obs they are Fualified for. Ma3imi0e H ofemployees matched to 9obs.

    /arriage0dating- /ertices represent men Iwomen and edges link a man I woman if theyare acceptable to each other as partners.

    B

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    37/84

    Bipartite graphs

    Abipartite graphis a (undirected) graphG= (V,E)whosevertices can be partitioned into two disjoint sets (V1,V2), withV1 V2= andV1 V2=V, such that for every edgeeE,e={u, v}such thatuV1 andvV2. In other words, every

    edge connects a vertex inV1 with a vertex in V2.

    Equivalently, a graph isbipartiteif and only ifit is possible to

    color each vertex red or blue such that no two adjacent vertices

    are the same color.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 1 / 9

    E l f Bi i G h

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    38/84

    Example of a Bipartite Graph

    V1 V2

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 2 / 9

    M hi i Bi i G h

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    39/84

    Matchings in Bipartite Graphs

    Amatching,M, in a graph,G= (V,E), is a subset of edges,ME, such that there does not exist two distinct edges inMthat are incident on the same vertex. In other words, if

    {u, v}, {w, z} M, then either{u, v}= {w, z}or{u, v} {w, z}= .

    Amaximum matchingin graphGis a matching inGwith the

    maximum possible number of edges.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 3 / 9

    P f / l hi

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    40/84

    Perfect/complete matchings

    For a graphG= (V,E), we say that a subset of edges, WE,coversa subset of vertices,A V, if for all verticesuA,there exists an edgeeW, such thateis incident onu, i.e.,such thate={u, v}, for some vertexv.

    In a bipartite graphG= (V,E)with bipartition(V1,V2), acomplete matchingwith respect toV1, is a matchingM

    Ethat coversV1, and aperfect matchingis a matching,M

    E,that coversV.

    Question: When does a bipartite graph have a perfectmatching?

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 4 / 9

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    41/84

    Halls Marriage Theorem

    For a bipartite graphG= (V,E), with bipartition(V1,V2), there

    exists a matchingMEthat coversV1 if and only iffor allSV1,|S| |N(S)|.

    Proof: ForG= (V,E), withA V, letNG(A)denote theneighbors ofAinG.

    First,only ifdirection: Suppose there is a matchingM inGthatcoversV1. We show thatSV1,|S| |NG(S)|. Suppose, forcontradiction, that there is a subsetSV1 such that|S| >|NG(S)|. Then no matchingMcould possibly coversS,because there arent enough neighborsN

    G(S

    ). Done.

    Theifdirection of the proof is harder...

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 5 / 9

    f f H ll Th ti d

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    42/84

    proof of Halls Theorem, continued...

    If direction: SupposeSV1,|S| |NG(S)|. Then we prove amatchingMexists which coversV1, byinductionon the size

    |V1|.

    Base case: |V1|= 1. Since|V1| |NG(V1)|, there must be an

    edge covering the vertexu inV1={u}.

    Inductive step: Suppose (byinductive hypothesis) that the

    claim holds for bipartite graphsG with|V1|=jk. Suppose

    |V1|=k+ 1.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 6 / 9

    f f H ll Th ( ti d)

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    43/84

    proof of Halls Theorem (continued)

    Case 1: Suppose that for every nonempty strict subsetSV1,we have|S| |NG(S)| 1. Take any{u, v} E, withuV1.

    Removeuandv(and the edges incident on them) from G. Call

    the resulting bipartite graphG, with bipartition

    (V1 {u},V2 {v}).By the induction hypothesis, there must exist a matching M inG that coversV1 {u}, because for every subset SV1 {u},NG(S) NG(S) {v}, and thus|NG(S)| |NG(S)| 1 |S|.But thenM=M {{u, v}}is a matching inGwhich coversV1.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 7 / 9

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    44/84

    Case 2: Suppose, on the contrary, that there exists a nonempty

    strict subsetSV1 with|S|=|NG(S)|.

    Any matching that coversV1 must matchStoNG(S).By the induction hypothesis, there is a matchingM covering S

    on the bipartite subgraphG ofGinduced byS NG(S). Andfurthermore, the bipartite subgraphG ofGinduced by

    (V1 S) (V2 NG(S))also satisfies the condition, andcontains a matchingM that covers(V1 S). This is because ifA V1 Shas|A| >|NG(A)|, this implies|A S| >|NG(A S)|, which violates the assumption about G.

    LettingM=M M,Mdefines a matching in Gthat covers

    V1.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 8 / 9

    M M t hi

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    45/84

    More on Matchings

    CorollaryA bipartite graph G= (V,E)with bipartition(V1,V2)has aperfectmatching if and only if|V1|= |V2|andS V1,|S| |NG(S)|.

    Unfortunately, the proof we have given isnot constructive

    enough: it doesnt yield an (efficient) algorithm to compute amaximum matching in a bipartite graph.

    An alternative proof of Halls theorem (which we do not give)

    based onalternating pathsandaugmenting paths, is

    constructive & yields an efficient (polynomial time) algorithm forcomputing a maximum matching.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 9 / 9

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    46/84

    New Graphs from 8ldDefinition: (he unionof two simple graphsG5# !V5, E5"and G7# !V7, E7"is the

    simple graph with /erte3 set V5JV7and edge

    set E5JE7. (he union of G5 and G7is denotedby G5J G7.

    Example:

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    47/84

    &epresenting Graphs: Ad9acency ?ists

    Definition: An ad1acenc$ list represents a

    graph !with no multiple edges" by specifyingthe /ertices that are ad9acent to each /erte3.

    Example:

    Example:

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    48/84

    &epresentation of Graphs:

    Ad9acency MatricesDefinition: +uppose that G; !V E" is a simplegraph where DVD ; n. Arbitrarily list the /erticesof Gas v(5 v(7 K v(n.

    (he ad1acenc$ matrix' of G with respect tothis listing of /ertices is the n 2n6-5 matri3with its !i1"th entry ; 5 when v(i and v(1aread9acent and ;6 when they are not ad9acent.

    *n other words: and:A=[aij]

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    49/84

    Ad9acency Matrices !continued"

    Example: 3he vertex ordering isisa b c d.

    (ote: (he ad9acency matri3 of an undirected graph is symmetric:

    Also since there are no loops each diagonal entry is 4ero5

    A sparsegraph has fewedges relati/e to thenumber of possibleedges. +parse graphsare more efficient torepresent using an

    ad9acency list than anad9acency matri3. utfor a densegraph anad9acency matri3 isoften preferable.

    aij=aji,i , j

    aii=0 ,i

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    50/84

    Ad9acency Matrices !continued"

    Ad9acency matrices can also be used torepresent graphs with loops and multi-edges.

    When multiple edges connect /ertices viandv1 !or if multiple loops present at the same/erte3" the !i1"th entry eFuals the number of

    edges connecting the pair of /ertices.Example: Ad9acency matri3 of a pseudographusing /erte3 ordering a b c d5

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    51/84

    Adjacency Matrices (continued)

    Adjacency matrices can represent directed

    graphs in exactly the same way. The matrix Afor a directed graph G= (V, E) has a 1 in its(i,j)th position if there is an edge from vi tovj, where v1, v2, vnis a list of the !ertices. "n other words,

    #ote$ the adjacency matrix for a directedgraph need not %e symmetric.

    aij=1 if (i , j)Eaij=0 if (i , j)E

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    52/84

    Isomorphism of Graphs

    Definition: Two (undirected) graphs

    G1 = (V1, E1)and G2= (V2, E2)areisomorphicif there is a bijection, ,

    with the property that for all ertices

    if and only if

    !uch a function f is called an isomorphism"

    Intuitiely, isomorphic graphs are #T$% !&'%,ecept for #renamed ertices"

    {f(a) , f(b)}E2

    a ,bV1

    f :V1V

    2

    {a ,b}E1

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    53/84

    *somorphism of Graphs !cont&"

    Example: +how that the graphs G;!V E" and

    H; !* +" are isomorphic.

    Solution: (he function fwith f!u5" ; v5f!u7" ; v

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    54/84

    *somorphism of Graphs !cont&"

    *t is difficult to determine whether two graphsare isomorphic by brute force: there are nbi9ections between /ertices of two n-/erte3graphs.

    8ften we can show two graphs are not

    isomorphic by finding a property that only oneof the two graphs has. +uch a property is calledgraph invariant: e.g. number of /ertices of gi/en degree the

    degree seFuence !list ofthe degrees" .....

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    55/84

    *somorphism of Graphs !cont&"

    Example: Are these graphs are isomorphic

    Solution: No +ince deg!a" ; 7 in G amustcorrespond to t ux or$,since these are the/ertices of degree 7 in ). ut each of these

    /ertices is ad9acent to another /erte3 of degree7 in H which is not true for ain G. +o G and) can not be isomorphic.

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    56/84

    *somorphism of Graphs !cont&"

    Example: 4etermine whether thesetwo graphs are isomorphic.

    Solution: (he function fis defined

    by: f!u5" ; v f!u7" ; vB f!uB" ;v

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    57/84

    Algorithms for Graph *somorphism

    (he best algorithms known for determiningwhether two graphs are isomorphic ha/ee3ponential worst-case time comple3ity !in

    the number of /ertices of the graphs".)owe/er there are algorithms with good

    time comple3ity in many practical cases.

    +ee e.g. a publicly a/ailable software calledNA1(' for graph isomorphism.

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    58/84

    Applications of Graph *somorphism

    (he Fuestion whether graphs are isomorphicplays an important role in applications of graphtheory. 2or e3ample:

    Chemists use molecular graphs to model chemical

    compounds. %ertices represent atoms and edgesrepresent chemical bonds. When a newcompound is synthesi0ed a database ofmolecular graphs is checked to determine

    whether the new compound is isomorphic to thegraph of an already known one.

    Section Summary

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    59/84

    Section Summary

    Paths

    Connectedness in Undirected Graphs

    (strong) Connectedness in Directed Graphs

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 1 / 20

    Paths (in undirected graphs)

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    60/84

    Paths (in undirected graphs)Informally, apathis a sequence of edges connecting vertices.

    Formally:

    Definition:For an undirected graphG= (V, E), an integern0, and verticesu, vV, apath (or walk) of lengthnfromutov inGis a sequence:

    x0,e1, x1, e2, . . . , xn1,en, xn

    of interleaved verticesxjVand edgeseiE,such thatx0=uandxn=v, and such thatei={xi1, xi} E foralli {1, . . . , n}.

    Such a pathstartsatuandendsatv. A path of lengthn1 iscalled acircuit(orcycle) ifn1 and the path starts and ends atthe same vertex, i.e.,u=v.

    A path or circuit is calledsimpleif it does not contain the same

    edge more than once.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 2 / 20

    More on paths

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    61/84

    More on pathsWhenG= (V,E)is asimple undirected grapha pathx0, e1, . . . , en, xnis determineduniquelyby the sequence of

    verticesx0

    , x1

    , . . . , xn

    . So, for simple undirected graphswe can

    denote a path by its sequence of verticesx0, x1, . . . , xn.

    Note 1: The word simple is overloaded. Dont confuse a

    simpleundirected graph with asimplepath. There can be a

    simple path in a non-simple graph, and a non-simple path in a

    simple graph.

    Note 2: The terms path and simple path used in Rosens

    book are not entirely standard. Other books use the terms

    walkandtrailto denote path and simple path, respectively.

    Furthermore, others use path itself to mean a walk that doesntre-visit any vertex, except possibly the first and last in case it is

    a circuit. To stick to Rosens terminology, we shall use the

    non-standardtermtidy pathto refer to such a walk.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 3 / 20

    Example

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    62/84

    ExampleHere is a simple undirected graph:

    a b c

    d g f

    d,a, b, c, f is a simple (and tidy) path of length 4.

    d,g, c, b,a,d is a simple (and tidy) circuit of length 5.

    a, b,g, f is nota path, because{b,g}is not an edge.

    d,a, b, c, f, b,a,g isa path, but itis nota simple path,because the edge{a,b}occurs twice in it.c,g,a, d, g, fis a simple path, but itis nota tidy path,

    because vertexgoccurs twice in it.Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 4 / 20

    Example: an acquantance graph

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    63/84

    Example: an acquantance graph

    Alice

    Bob

    Kathy

    David

    Ellen

    Fred

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 5 / 20

    Paths in directed graphs (same definitions)

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    64/84

    Paths in directed graphs (same definitions)

    Definition:For an directed graphG= (V, E), an integern0,and verticesu, vV, apath (or walk) of lengthnfromutov in

    Gis a sequence of vertices and edges x0,e1, x1, e2, . . . , xn,en,such thatx0 =uandxn=v, and such thatei= (xi1, xi)E foralli {1, . . . , n}.

    When there are no multi-edges in the directed graph G, the path

    can be denoted (uniquely) by its vertex sequencex0, x1, . . . , xn.

    A path of lengthn1 is called acircuit(orcycle) if the pathstarts and ends at the same vertex, i.e.,u=v.

    A path or circuit is calledsimpleif it does not contain the same

    edge more than once. (And we call ittidyif it does not containthe same vertex more than once, except possibly the first and

    last in caseu=vand the path is a circuit (cycle).)

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 6 / 20

    Connectness in undirected graphs

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    65/84

    Connectness in undirected graphs

    Definition:An undirected graphG= (V, E)is calledconnected,if there is a path between every pair of distinct vertices.

    It is calleddisconnnectedotherwise.

    a

    b

    c

    d e

    f

    This graph is connected

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 7 / 20

    Connectness in undirected graphs

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    66/84

    Connectness in undirected graphs

    Definition:An undirected graphG= (V, E)is calledconnected,if there is a path between every pair of distinct vertices.

    It is calleddisconnnectedotherwise.

    a

    b

    c

    d e

    f

    This graph is connected

    a

    b

    c

    d e

    f

    This graph isnotconnected

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 7 / 20

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    67/84

    Proposition

    There is always a simple, and tidy, path between any pair ofverticesu, vof a connected undirected graphG.

    Proof: By definition of connectedness, for every pair of vertices

    u, v, there must exist ashortestpathx0,e1, x1, . . . , en, xn inG

    such thatx0 =uandxn=v.Suppose this path is not tidy, andn1. (Ifn=0, theProposition is trivial.) Thenxj=xkfor some 0j

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    68/84

    connected components of undirected graphs

    Definition:Aconnected componentH= (V,E)of a graph

    G= (V,E)is amaximalconnected subgraph ofG, meaningHis connected andV V andE E, butHis not a propersubgraph of a larger connected subgraph RofG.

    a

    b

    c

    d e

    f

    g h

    This graph,G= (V, E), has 3 connected components.

    (It is thus a disconnected graph.)One connected component ofGisH1= (V

    1, E

    1),whereV1={d,a,b}andE

    1 ={{d, a}, {d, b}}.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 9 / 20

    Connectedness in directed graphs

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    69/84

    Connectedness in directed graphs

    Definition:A directed graphG= (V,E)is calledstronglyconnected, if for every pair of vertices uandv inV, there is a

    (directed) path fromutov,anda directed path fromv tou.

    (G= (V, E)isweakly connectedif there is a path between

    every pair of vertices inVin the underlying undirected graph(meaning when we ignore the direction of edges in E.)

    Astrongly connected component (SCC)of a directed graph G,

    is a maximal strongly connected subgraphHofGwhich is not

    contained in a larger strongly connected subgraph ofG.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 10 / 20

    Example

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    70/84

    Example

    a

    b

    c

    d e

    f

    This digraph,G, isnotstrongly connected, because, for

    example, there is no directed path frombtoc.

    Question: what are the strongly connected components (SCCs)ofG?

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 11 / 20

    Example

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    71/84

    Example

    a

    b

    c

    d e

    f

    This digraph,G, isnotstrongly connected, because, for

    example, there is no directed path frombtoc.

    Question: what are the strongly connected components (SCCs)ofG?

    One strongly connected component (SCC) ofGisH1 = (V

    1, E

    1),whereV1={d,a,b}andE

    1 ={(d,a),(a, b),(b,d)}.

    Another SCC ofGisH2= (V

    2,E

    2), whereV

    2={e, c, f}andE2={(e, c),(c, f),(f,e)}.

    There are no other SCCs in G.Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 11 / 20

    Directed Acyclic Graphs

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    72/84

    Directed Acyclic Graphs

    ADirected Acyclic Graph (DAG), is a directed graph that

    contains no circuits or loops.

    Example:

    a

    b

    c

    d

    e

    f

    a

    b

    c

    d

    e

    f

    This is a DAG This is NOT a DAG

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 12 / 21

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    73/84

    Euler Paths and Euler Circuits

    Hamiltonian Paths and Hamiltonian Circuits

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 12 / 20

    The Knigsberg Bridge Problem

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    74/84

    e gsbe g dge ob eLeonard Euler (1707-1783) was asked to solve the following:

    Question: Can you start a walk somewhere in Knigsberg, walk

    across each of the 7 bridgesexactly once, and end up back

    where you started from?

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 13 / 20

    The Knigsberg Bridge Problem

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    75/84

    g g gLeonard Euler (1707-1783) was asked to solve the following:

    Question: Can you start a walk somewhere in Knigsberg, walk

    across each of the 7 bridgesexactly once, and end up back

    where you started from?

    Euler (in 1736) used graph theory to answer this question.

    A

    B

    C

    D

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 13 / 20

    Euler paths and Euler Circuits

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    76/84

    p

    Recall that an (undirected)multigraphdoes not have any loops,

    but can have multiple edges between the same pair of vertices.

    Definition: AnEuler pathin a multigraphGis a simple path that

    contains every edge ofG.

    (So, every edge occurs exactly once in the path.)

    AnEuler circuitin an multigraphGis a simple circuit thatcontains every edge ofG.

    (So, every edge occurs exactly once in the circuit.)

    Question: Is there a simple criterion for determining whether a

    multigraph Ghas an Euler path (an Euler circuit)?

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 14 / 20

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    77/84

    Eulers Theorem

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    78/84

    Eulers Theorem (1736)

    A connected undirected multigraph with at least two vertices hasan Euler circuit if and only if each of its vertices has even

    degree.

    Proof: Only if direction:Suppose a multigraphG= (V,E)has

    an Euler circuit,x0e1x1e2. . . emxm, wherex0 =xm=u.For every vertexvV,v=u, each time we entervvia an edgeei, we must leavevvia a different edgeei+1. So, in total, since

    we see all edges incident tovexactly once, all such verticesv

    must have even degree.

    Likewise, the initial (and final) vertexu=x0=xm, must alsohave even degree, because the edgese1andempair up in the

    same way.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 15 / 20

    Proof of Eulers Theorem (continued)

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    79/84

    ( )

    The(harder)if direction:SupposeG= (V,E)is connectedand every vertex inVhas even degree.

    We give aconstructive proofthat, given such a multigraphG,shows how to construct an Euler circuit (efficiently).

    Start a walk at any vertexv, never re-using an edge, walking

    for as long as possible until you can not do so any more.

    Claim: Such a walk (simple path),w1, must end at the vertexv

    where it started (i.e., it must be a circuit).

    Reason: For any vertexzother thanv, whenever the walk

    enterszvia an edge, there must be an odd number of edges

    incident tozremaining. Note: zero is not an odd number! After

    leavingz, there must be an even number of edges ofzremaining.

    If the simple circuitw1 covers every edge of G, we are done.

    If not, .....

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 16 / 20

    Proof of Eulers theorem (final part)

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    80/84

    ( p )Note that every vertex has even degree remaining after the

    edges of the simple circuitw1 are removed.

    If the simple circuitw1 does not cover every edge ofG, sinceGis connected, there must be some vertex x on the circuitw1which is incident to an edge not inw1. So,w1=w

    1xw

    1

    We start a new walk at the vertex x, on the remaining graph

    without the edges ofw1. This yields a new circuitw2 that must

    start and end atx

    .We can then then splice w2 insidew1 (at the point wherex

    occurs) in order to get a new longer Euler circuit: w1w2w

    1 .

    We can do this same process repeatedly until there are no

    edges remaining.

    Note: this also yields a reasonably efficient algorithm for

    computing an Euler circuit in a connected multigraph where

    every vertex has even degree.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 17 / 20

    Eulers theorem for paths

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    81/84

    p

    Eulers Theorem for pathsA connected undirected multigraphGhas an Euler path which is

    notan Euler circuit if and only if Ghas exactly two vertices of

    odd degree.

    The proof is very similar to the case of Euler circuits: just start

    the initial walk at one of the vertices of odd degree.

    The proof is thus similarly constructive, and yields an efficient

    algorithm to construct an Euler path, if one exists.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 18 / 20

    Hamiltonian Paths

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    82/84

    Definition: AHamiltonian pathin a (undirected) graph Gis a

    simple path that visits every vertex exactly once. (In other

    words, it is a tidy path that visits every vertex.)

    AHamiltonian circuitin a (undirected) graphGis a simple circuit

    that passes through every vertex exactly once (except for the

    common start and end vertex, which is seen exactly twice).

    Question: Is there a simple criterion for determining whether a

    (simple undirected) graph has a Hamiltonian path, or

    Hamiltonian circuit?

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 19 / 20

    Hamiltonian Paths

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    83/84

    Definition: AHamiltonian pathin a (undirected) graph Gis a

    simple path that visits every vertex exactly once. (In other

    words, it is a tidy path that visits every vertex.)

    AHamiltonian circuitin a (undirected) graphGis a simple circuit

    that passes through every vertex exactly once (except for the

    common start and end vertex, which is seen exactly twice).

    Question: Is there a simple criterion for determining whether a

    (simple undirected) graph has a Hamiltonian path, or

    Hamiltonian circuit?

    Answer: No. Nobody knows any efficient algorithm fordetermining whether a given (arbitrary) graphGhas a

    Hamiltonian path/circuit. The problem is NP-complete.

    Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 19 / 20

    More on Hamiltonian paths/circuits

  • 8/9/2019 Ch10 Discrete Mathematics Direct Graph

    84/84

    p

    There aresufficientcriteria that guarantee existence of a

    Hamiltonian circuit. For example:

    Ores TheoremEvery simple undirected graph,G= (V,E), withn3 vertices,in whichdeg(u) + deg(v)nfor every two non-adjacentverticesuandv inV, has a Hamiltonian circuit.

    Corollary (Diracs Theorem)

    Every simple undirected graph,G= (V,E), withn3 vertices,in whichdeg(u)n/2 for all verticesuV, has a Hamiltonian

    circuit.

    We will NOT prove these theorems, and we will NOT