An Introduction to Graph Theory

Embed Size (px)

Citation preview

  • 7/29/2019 An Introduction to Graph Theory

    1/32

    An Introduction to Graph Theory

    Course 2

    Crina Grosan

  • 7/29/2019 An Introduction to Graph Theory

    2/32

    The Konigsberg Bridge Problem

  • 7/29/2019 An Introduction to Graph Theory

    3/32

    Undirected graph Directed graph

    isolated vertex

    adjacent

    loop

    multipleedges

    simple graph: an undirected graph without loop or multiple edges

    degree of a vertex: number of edges connected (indegree, outdegree)

    G=(V,E)

    For simple graphs, deg(v Eiv Vi

    ) | | = 2

    Definitions and Examples

  • 7/29/2019 An Introduction to Graph Theory

    4/32

    x y

    path: no vertex can be repeateda-b-c-d-e

    trail: no edge can be repeata-b-c-d-e-b-d

    walk: no restrictiona-b-d-a-b-c

    closed if x = yclosed trail: circuit (a-b-c-d-b-e-d-a,

    one draw without lifting pen)closed path: cycle (a-b-c-d-a)

    a

    b

    c

    d

    e

    length: number of edges inthis (path,trail,walk)

    Definitions and Examples

  • 7/29/2019 An Introduction to Graph Theory

    5/32

    .tofrompatha

    isethen ther,tofromtrailaexiststhereIf.,,

    withgraph,undirectedanbe),(=LetTheorem.

    ba

    babaVba

    EVG

    a x b

    remove any cycle on the repeatedvertices

    Definition. Let G=(V,E) be an undirected graph. We call Gconnectedif there is a path between any two distinct vertices ofG.

    a

    b

    c

    d

    e a

    b

    c

    d

    e

    disconnected with

    two components

    Definitions and Examples

  • 7/29/2019 An Introduction to Graph Theory

    6/32

    multigraph ofmultiplicity3

    multigraphs

    Definitions and Examples

  • 7/29/2019 An Introduction to Graph Theory

    7/32

    Definitions and Representation

    An undirected graph and its adjacency matrix representation.

    An undirected graph and its adjacency list representation.

  • 7/29/2019 An Introduction to Graph Theory

    8/32

    .inesith verticincident wisin

    ofedgeeachwhere,andifofsubgrapha

    calledis),(thengraph,ais),(=If.Definition

    11

    11

    111

    VE

    EEVVG

    EVGEVG

    =

    a

    b

    cd

    e

    a

    b

    c

    d

    e

    b

    c

    d

    ea

    cd

    spanning subgraph

    V1=V

    Subgraphs, Complements, and Graph Isomorphism

  • 7/29/2019 An Introduction to Graph Theory

    9/32

    Definition: complete graph: Kn

    a

    b

    c

    d

    e

    K5

    Definition: complement of a graph

    G Ga

    b

    c

    d

    e

    a

    b

    c

    d

    e

    Subgraphs, Complements, and Graph Isomorphism

  • 7/29/2019 An Introduction to Graph Theory

    10/32

    Graph Isomorphism

    1 2

    3 4

    a b

    c

    d

    w x y z

    .Ginadjacentare(y)and(x)ifonlyandifGinadjacentareGofyandxverticesany twoifmisomorphis

    graphacalledis:functionAgraphs.undirected

    twobe),(and),(Let.Definition

    2

    1

    21

    222111

    VVf

    EVGEVG

    ==

    Subgraphs, Complements, and Graph Isomorphism

  • 7/29/2019 An Introduction to Graph Theory

    11/32

    Example q r

    w

    z xy

    u t

    v

    a

    b

    cd

    ef

    g

    h

    i

    j

    a-q c-u e-r g-x i-z b-v d-y f-w h-t j-s, isomorphic

    Example

    Subgraphs, Complements, and Graph Isomorphism

    a

    b c

    d

    ef

    1

    23

    4

    56

  • 7/29/2019 An Introduction to Graph Theory

    12/32

    Regular graphs

    A graph is said to be regular of degree if all local

    degrees are the same number . A 0-regular graph isan empty graph, a 1-regular graph consists of

    disconnected edges, and a 2-regular graph consists of

    disconnected cycles. The first interesting case is therefore

    3-regular graphs, which are called cubic graphs.

  • 7/29/2019 An Introduction to Graph Theory

    13/32

    For simple graphs, deg(v Eiv Vi ) | |

    = 2Theorem.

    Corollary . The number of vertices of odd degree must be even.

    Example: a regulargraph: each vertex has the same degree

    Is it possible to have a 4-regular graph with 10 edges?

    2|E| = 4|V| = 20, |V|=5 possible (K5)

    with 15 edges?

    2|E| = 4|V| = 30

    Vertex Degree: Euler Trails and Circuits

    not possible!!!

  • 7/29/2019 An Introduction to Graph Theory

    14/32

    a

    Find a way to walk about the city so as to cross each bridge exactlyonce and then return to the starting point.

    The Seven Bridge of Konigsberg

  • 7/29/2019 An Introduction to Graph Theory

    15/32

    Definition. Let G=(V,E) be an undirected graph or multigraph with noisolated vertices. Then Gis said to have an Euler circuitif there is a circuitin G that traverses every edge of the graph exactly once. If there is anopen trail from ato bin Gand this trail traverses each edge in Gexactlyonce, the trail is called an Euler trail.

    Theorem. Let G=(V,E) be an undirected graph or multigraph with noisolated vertices. Then Ghas an Euler circuit if and only ifGis connected

    and every vertex in G has even degree.

    All degrees are odd. Hence no Euler circuitfor the Konigsberg bridges problem !

    Vertex Degree: Euler Trails and Circuits

  • 7/29/2019 An Introduction to Graph Theory

    16/32

    Corollary. An Euler trail exists in Gif and only ifGis connected and has exactlytwo vertices of odd degree.

    two odd degree vertices

    a b

    add an edge

    Theorem. A directed Euler circuit exists in Gif and only ifGis connectedand in-degree(v)=out-degree(v) for all vertices v.

    two in, two out

    Can you think of an algorithm to construct an Euler circuit?

    Vertex Degree: Euler Trails and Circuits

  • 7/29/2019 An Introduction to Graph Theory

    17/32

    ExerciseEuler's House. Baby Euler has just learned to walk. He is curious to know if he can

    walk through every doorway in his house exactly once, and return to the room he

    started in. Will baby Euler succeed? Can baby Euler walk through every door exactly

    once and return to a different place than where he started? What if the front door is

    closed?

  • 7/29/2019 An Introduction to Graph Theory

    18/32

    Definition. A graph (or multigraph) Gis calledplanarifGcan be drawn in theplane with its edges intersecting only at vertices ofG.Such a drawing ofGis called an embeddingofGin the plane.

    Example: K1,K2,K3,K4 are planar, Kn for n>4 are nonplanar.

    K4 K5

    applications: VLSI routing, plumbing,...

    Planar Graphs

  • 7/29/2019 An Introduction to Graph Theory

    19/32

    bipartite graph complete bipartite graphs (Km,n)

    K4,4

    K3,3 is not planar.

    Planar Graphs

  • 7/29/2019 An Introduction to Graph Theory

    20/32

    elementary subdivision (homeomorphic operation)

    u w u v w

    Definition. G1 and G2 are called homeomorphicif they are isomorphic or ifthey can both be obtained from the same loop-free undirected graph Hby a

    sequence of elementary subdivisions.

    a b

    cde

    a b

    cde

    a b

    cde

    a b

    cde

    Two homeomorphic graphs are simultaneously planar or nonplanar.

    Planar graphs

  • 7/29/2019 An Introduction to Graph Theory

    21/32

    Degree of a region (deg(R)): the number of edges traversed in a shortestclosed walk about the boundary ofR.

    R1

    R2

    R3

    R4R5

    R6

    R7

    R8

    two different embeddings

    deg(R1)=5,deg(R2)=3

    deg(R3)=3,deg(R4)=7

    deg(R5)=4,deg(R6)=3

    deg(R7)=5,deg(R8)=6

    deg( ) deg( ) | |R R Eii

    ii= =

    = = = =1

    4

    5

    818 2 9 2

    abghgfda

    a b

    c

    d fg h

    Planar Graphs

  • 7/29/2019 An Introduction to Graph Theory

    22/32

    a b

    c

    d

    ef

    g

    1 2

    3

    4

    5

    6

    1

    6 5

    4

    2

    3

    An edge in Gcorresponds with an edge in Gd.

    It is possible to have isomorphic graphs with respective duals thatare not isomorphic.

    A dual graph of a planar graph

  • 7/29/2019 An Introduction to Graph Theory

    23/32

    Cut-set: a subset of edges whose removal increase the number ofcomponents

    Example

    a

    b

    c

    d

    e

    f

    g

    h

    cut-sets: {(a,b),(a,c)},{(b,d),(c,d)},{(d,f)},...

    a bridge

    For planar graphs, cycles in one graph correspond to cut-setsin a dual graphs and vice versa.

    Cut set

  • 7/29/2019 An Introduction to Graph Theory

    24/32

    a path or cycle that contain every vertex

    Unlike Euler circuit, there is no knownnecessary and sufficient condition for agraph to be Hamiltonian.

    Examplea b c

    d e f

    g h

    i

    There is a Hamilton path, but no

    Hamilton cycle.

    an NP-complete problem

    Hamilton Paths and Cycles

  • 7/29/2019 An Introduction to Graph Theory

    25/32

    Examplex

    yy y y

    x x

    x

    y

    y

    start labeling from here

    4x's and 6y's, since xand ymustinterleave in a Hamilton path (or cycle),the graph is not Hamiltonian

    The method works only for bipartite graphs.

    The Hamilton path problem is still NP-complete when restrictedto bipartite graphs.

    Hamilton Paths and Cycles

  • 7/29/2019 An Introduction to Graph Theory

    26/32

    Exercise. 17 students sit at a circular table, how many sittings arethere such that one has two different neighbors each time?

    Consider K17, a Hamilton cycle in K17 corresponds to a seatingarrangements. Each cycle has 17 edges, so we can have(1/17)17(17-1)/2=8 different sittings.

    12

    3

    4

    5

    6

    17

    16

    15

    1,2,3,4,5,6,...,17,1

    12

    3

    4

    5

    6

    17

    16

    15

    1,3,5,2,7,4,...,17,14,16,1

    12

    3

    4

    5

    6

    17

    16

    15

    1,5,7,3,9,2,...,16,12,14,1

    14

    Hamilton Paths and Cycles

  • 7/29/2019 An Introduction to Graph Theory

    27/32

    path.Hamiltondirectedacontainsalways)

    a(calledgraphaSuch.inis),(or),(edgestheofone

    exactlyvertices,of,pairdistinctanyforandverticeshas

    i.e.,graph,directedcompleteabeLetTheorem.

    *

    **

    tournament

    Kxyyx

    yxn

    KK

    n

    nn

    Hamilton Paths and Cycles

  • 7/29/2019 An Introduction to Graph Theory

    28/32

    cycle.Hamiltonacontainscontainsthen,,

    tnonadjacenallfor)(deg+)deg(If3.|=|with

    graphundirectedfree-loopabe),(=LetTheorem.

    path.Hamiltonahas

    graphthen thevertices,allfor2

    1-

    )deg(IfCorollary.

    GVyx

    nyxnV

    EVG

    nv

    Hamilton Paths and Cycles

  • 7/29/2019 An Introduction to Graph Theory

    29/32

    A related problem: the traveling salesman problem

    a

    b

    c

    d

    e3

    4

    13

    5 4

    32 Find a Hamilton cycle of shortest total distance.

    2

    For example, a-b-e-c-d-a with total cost=

    1+3+4+2+2=12.

    Hamilton Paths and Cycles

  • 7/29/2019 An Introduction to Graph Theory

    30/32

    Definition. IfG=(V,E) is an undirected graph, a proper coloring ofGoccurs whenwe color the vertices ofGso that if (a,b) is an edge in G, then aand bare coloredwith different colors. The minimum number of colors needed to properly color Giscalled the chromatic number ofG.

    b

    c

    d

    e

    a3 colors are needed.

    a: Redb: Green

    c: Red

    d: Blue

    e: Red

    In general, it's a very difficult problem (NP-complete).

    (Kn)=n

    (bipartite graph)=2

    Graph Coloring and Chromatic Polynomials

  • 7/29/2019 An Introduction to Graph Theory

    31/32

    A related problem: color the map where two regions arecolored with different colors if they have same boundaries.

    G

    R e

    B

    B

    R

    Y

    Four colors are enough for any map. Remaina mystery for a century. Proved with the aid

    of computer analysis in 1976.

    a b

    c

    d

    f

    a

    b

    c

    d

    e

    f

    Graph Coloring and Chromatic Polynomials

  • 7/29/2019 An Introduction to Graph Theory

    32/32

    P(G,): the chromatic polynomial ofG=the number of ways

    to color Gwith colors.

    Example

    (a) G=n isolated points, P(G,)=n.

    (b) G=Kn, P(G,)=(-1)(-2)...(-n+1)=(n)

    (c) G=a path ofn vertices, P(G,)=(-1)n-1.

    (d) IfGis made up of components G1, G

    2, ..., G

    k,

    then P(G,)=P(G1,)P(G2,)...P(Gk,).

    Example

    e

    G eG eG'

    coalescing the vertices

    Graph Coloring and Chromatic Polynomials