basics of graph theory

Embed Size (px)

Citation preview

  • 8/14/2019 basics of graph theory

    1/31

    Graphs

    Nitin Upadhyay

    February 24, 2006

  • 8/14/2019 basics of graph theory

    2/31

    Discussion

    What is a Graph?

    Applications of Graphs

    Categorization

    Terminology

  • 8/14/2019 basics of graph theory

    3/31

    What is a Graph?

    A graph G=(V,E) consists of a finitenonempty set V, the elements of which are

    the verticesof G, and a finite set Eof

    unordered pairs of distinct elements ofV

    called edges.

    G = ( V, E )

    Where, V- set of vertices

    E - set of edges

    1

    2

    3

    4

    5

    Vertex

    (Node)Edge

    V = {1, 2, 3, 4, 5}

    E = { (1,2), (1,3), (1,4), (2,3), (3,5), (4,5) }

  • 8/14/2019 basics of graph theory

    4/31

    Graph applications

    Graphs can be used for: Finding a route to drive from one city to another Finding connecting flights from one city to another Determining least-cost highway connections

    Designing optimal connections on a computer chip Implementing automata Implementing compilers Doing garbage collection Representing family histories Doing similarity testing (e.g. for a dating service) Pert charts Playing games

  • 8/14/2019 basics of graph theory

    5/31

    Graph applications

    Computer Networks

    Electrical Circuits

    Road Map

    Computer

    Resistor/Inductor/

    City

  • 8/14/2019 basics of graph theory

    6/31

    Graph Models

    Acquaintanceship Graphs showing whether two people know eachother, that is, whether they are acquainted.

    Influence Graphs showing whether a person can influence another(e.g., ab) by using a directed graph.

    The Bollywood Graph showing whether the actors have workedtogether in a movie.

    Round-Robin Tournaments showing if team a beats team b (usingan edge (a, b)) via a directed graph.

    Collaboration Graphs modeling joint authorship of academic papers(an edge links two people if they have jointly written a paper).

    Call Graphs modeling telephone calls made in a network (can useeitherdirected multigraphs orundirected ones, depending on the

    interest) The Web Graph representing hyperlinks between Web pages using a

    directed graph. E.g., Web page a links to Web page b via an edgepointing from a to b.

  • 8/14/2019 basics of graph theory

    7/31

    Structure of the Internet

    Europe

    Japan

    Backbone 1

    Backbone 2

    Backbone 3

    Backbone 4, 5, N

    Australia

    Regional A

    Regional B

    NAP

    NAP

    NAP

    NAP

    MAPS UUNET MAP

    SOURCE: CISCO SYSTEMS

    http://www.caida.org/tools/visualization/mapnet/Backbones/http://www.uunet.com/network/maps/http://www.uunet.com/network/maps/http://www.caida.org/tools/visualization/mapnet/Backbones/
  • 8/14/2019 basics of graph theory

    8/31

    Graph Models Where are we right now?

  • 8/14/2019 basics of graph theory

    9/31

    Graph categorization

    Simple Graphs

    Multigraphs

    Pseudographs

    Directed Graphs

    Directed Multigraphs

    Weighted Graph

  • 8/14/2019 basics of graph theory

    10/31

    Simple Graphs

    A simple graphG = (V,E)

    consists of: a set Vofvertices ornodes

    (Vcorresponds to the

    universe of the relation R),

    a set Eofedges / arcs / links: unordered pairs of

    distinct elements u, v

    V, such that uRv.

  • 8/14/2019 basics of graph theory

    11/31

    Multigraphs

    Like simple graphs, but there may be more than one

    edge connecting two given nodes.

    A multigraphG=(V, E, f) consists of a set Vof

    vertices, a set Eof edges (as primitive objects), anda function ffrom Eto

    {{u,v}| u,vVuv}.

    The edges e1 and e2 are called multiple

    or parallel edges if f(e1) = f(e2).

    E.g., nodes are cities, edges

    are segments of major highways

    Parallel edges

  • 8/14/2019 basics of graph theory

    12/31

    Pseudographs

    Like a multigraph, but edges connecting a

    node to itself are allowed.

    ApseudographG=(V, E, f) where

    f:E{{u,v}|u,vV}. Edge eEis

    a loop iff(e)={u,u}={u}.

    E.g., nodes are campsites

    in a state park, edges arehiking trails through the woods.

    Self loops

  • 8/14/2019 basics of graph theory

    13/31

    Directed Graphs

    Correspond to arbitrary binary relations R,

    which need not be symmetric.

    A directed graph (V,E) consists of a set of

    vertices Vand a binary relation Eon V.

    E.g.: V= people,

    E={(x,y) |xloves y}

  • 8/14/2019 basics of graph theory

    14/31

    Directed Multigraphs

    Like directed graphs, but there may be more

    than one arc from a node to another.

    A directed multigraphG=(V, E, f) consists of

    a set Vof vertices, a set Eof edges, and afunction f:EVV.

    E.g., V=web pages,

    E=hyperlinks. The WWW isa directed multigraph...

  • 8/14/2019 basics of graph theory

    15/31

    Weighted Graph

    A Weighted Graph is a graph where all theedges are assigned weights

    1

    2

    3

    4

    5

    50

    4020

    30

    40

    30

  • 8/14/2019 basics of graph theory

    16/31

    Graph Terminology

    Adjacent, connects, endpoints, degree, initial,

    terminal, in-degree, out-degree, complete,

    cycles, wheels, n-cubes, bipartite, subgraph,

    union.

  • 8/14/2019 basics of graph theory

    17/31

    Adjacency

    Let G be an undirected graph with vertices u

    and v, and a linking edge e = {u,v}. Then we

    say:

    u, vare adjacent/ neighbors / connected. Edge e is incident with vertices uand v.

    Edge econnectsuand v.

    Vertices uand vare endpoints of edge e.

  • 8/14/2019 basics of graph theory

    18/31

    Adjacency

    Adjacent vertices: If (i,j) is an edge of the

    graph, then the nodes i and j are adjacent

    An edge (i,j) is Incidenttovertices i and j

    1

    2

    3

    4

    5

    Vertices 2 and 5 are not

    adjacent

  • 8/14/2019 basics of graph theory

    19/31

    Degree of a Vertex

    Let G be an undirected graph with vertex v.

    The degree ofv, deg(v), is its number of

    incident edges. (Except that any self-loops

    are counted twice.) A vertex with degree 0 is isolated.

    A vertex of degree 1 ispendant.

  • 8/14/2019 basics of graph theory

    20/31

    A Degree Example

    What are the degrees of the vertices in

    the graphs G and Has shown below?In G, deg(a) = 2, deg(b) = deg(c) = deg(f) = 4,

    deg(d) = 1, deg(e) = 3 and deg(g) = 0

    In H, deg(a) = 4, deg(b) = deg(e) = 6, deg(c) = 1,

    deg(d) = 5

    a

    b c d

    ef g

    a b c

    de

  • 8/14/2019 basics of graph theory

    21/31

    Handshaking Theorem

    Let G = (V, E) be an undirected (simple,

    multi-, or pseudo-) graph with e edges. Then

    Corollary: Any undirected graph has an even

    number of vertices of odd degree.

  • 8/14/2019 basics of graph theory

    22/31

    Handshaking TheoremExample How many edges are there in a graph with

    ten vertices each of degree six?

    The sum of the degrees of the vertices is 6x10 = 60,

    it follows that 2e = 60. Therefore, e = 30.

  • 8/14/2019 basics of graph theory

    23/31

    Directed Adjacency

    Let G be a directed (possibly multi-) graph,

    and let e be an edge ofG that is (or maps to)

    (u,v). Then we say:

    uis adjacent tov, vis adjacent fromu ecomes from u, e goes to v.

    e connects u to v, e goes from u to v

    the initial vertexofe is u the terminal vertexofe is v

  • 8/14/2019 basics of graph theory

    24/31

    Directed Degree

    Let G be a directed graph, va vertex ofG. The in-degree ofv, deg(v), is the number of

    edges going to v.

    The out-degree ofv, deg+(v), is the number ofedges coming from v.

    The degree ofv, deg(v)deg(v)+deg+(v), is the

    sum ofvs in-degree and out-degree.

  • 8/14/2019 basics of graph theory

    25/31

    Directed HandshakingTheorem Let G = (V, E) be a directed (possibly multi-)

    graph with vertex set Vand edge set E.

    Then:

    Note that the degree of a node is unchanged

    by whether we consider its edges to bedirected or undirected.

  • 8/14/2019 basics of graph theory

    26/31

    Path

    Path: A sequence of edges in the graph There can be more than one path between

    two vertices

    Vertex A is reachable from B if there is a pathfrom A to B

    A

    D

    C

    F

    E

    B

    G

    Paths from B to D

    - B, A, D- B, C, D

    -

  • 8/14/2019 basics of graph theory

    27/31

    Path

    Simple Path:A path whereall the vertices are

    distinct

    1

    2

    3

    45

    1,4,5,3 is a simplepath.

    But 1,4,5,4 is not asimple path.

  • 8/14/2019 basics of graph theory

    28/31

    Length

    Length :Sum of the lengths of the edges on

    the path.

    Length of the path1,4,5,3 is 3

    1

    2

    3

    45

  • 8/14/2019 basics of graph theory

    29/31

    Circuit

    Circuit: A path whose first and last vertices

    are the same

    The path 3,2,1,4,5,3

    is a circuit.

    1

    2

    3

    45

  • 8/14/2019 basics of graph theory

    30/31

    Cycle

    Cycle: A circuit where all the vertices are

    distinct except for the first (and the last)

    vertex

    1,4,5,3,1 is a cycle

    1,4,5,4,1 is not a cycle

    1

    2

    3

    45

  • 8/14/2019 basics of graph theory

    31/31