intro to graph theory

Upload: tanyananda

Post on 03-Jun-2018

232 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Intro to Graph Theory

    1/23

    1

  • 8/13/2019 Intro to Graph Theory

    2/23

    2

    Graph theory? Has nothing to do with graph or graphics

    An area of math dealing with entities (nodes) andthe connections (links) between the nodes

  • 8/13/2019 Intro to Graph Theory

    3/23

    3

    A graph is an abstract mathematicalstructure defined from two sets:

    V={n1, n2,nm} of nodes E={e1,e2,em} of edges

  • 8/13/2019 Intro to Graph Theory

    4/23

    4

    n1

    n6

    n7

    n3

    n5n4

    n2e1

    e5

    e3

    e4e2

  • 8/13/2019 Intro to Graph Theory

    5/23

    5

    The degree Refers to the number of edges that have a node

    as an endpoint , denoted by deg(n)

    Indicates the extent of integration testing that isappropriate for the object

    E.g. deg(n1) =2

  • 8/13/2019 Intro to Graph Theory

    6/23

    6

    Alternative to visual presentation ofgraph

    The incidence matrix of G=(V,E) with mnodes and n edges is an mn matrix

    We have 1 in row i, column J if node i is an endpoint of edge j

    Row sum represents degree of nodes Column sum represents the endpointsof an

    edge

  • 8/13/2019 Intro to Graph Theory

    7/237

    e1 e2 e3 e4 e5

    n1 1 1 0 0 0

    n2 1 0 0 1 0

    n3 0 0 1 0 0

    n4 0 1 1 0 1

    n5 0 0 0 1 0n6 0 0 0 0 1

    n7 0 0 0 0 0

  • 8/13/2019 Intro to Graph Theory

    8/238

    A useful supplement to the incidencematrix

    The Adjacency matrix of G=(V,E) with m

    nodes and n edges is an mm matrix We have 1 in row i, and col. j if

    there is an edge between node i and node j,

    zero otherwise

    Used to identify paths and henceequivalence relation to simplify a graphand hence testing

  • 8/13/2019 Intro to Graph Theory

    9/239

    n1 n2 n3 n4 n5 n6 n7

    n1 0 1 0 1 0 0 0

    n2 1 0 0 0 1 0 0

    n3 0 0 0 1 0 0 0

    n4 1 0 1 0 0 1 0

    n5 0 1 0 0 0 0 0n6 0 0 0 1 0 0 1

    n7 0 0 0 0 0 0 0

  • 8/13/2019 Intro to Graph Theory

    10/2310

    A path is a sequenceof edges such that,for any adjacent pairof edges ei, ej in the

    sequence, the edgesshare a common(node) endpoint

    Can be described assequences of edgesor nodes

    path Nodes

    sequence

    Edge

    sequences

    Between

    n1 and n5

    n1,n2,n5 e1,e4

    Between

    n6 and n5

    n6, n4, n1,

    n2, n5

    e5,e2,e1,e4

    .

  • 8/13/2019 Intro to Graph Theory

    11/2311

    Nodes niand njare connected if they arein the same path

    Connectedness is an equivalence

    relation can be checked easily Reflexive (every node is in path of 0 length with

    itself)

    Symmetric n1, and n2 in same path, then n2 and

    n1 is also in the same path transitive

  • 8/13/2019 Intro to Graph Theory

    12/2312

    Connectedness defines a partition (orcomponent) on the node set of a graph Components of a graph is maximal set of

    connected nodes E.g. Components

    S1={n1,n2,n3,n4,n5,n6} and S2={n7}

    Condensation graph Used as a Simplification mechanism Creating a graph by replacing a set of

    connected nodes (or components) by acondensing node

    The implication for testing is that component

    are stand alone elements and hence can betested separately

  • 8/13/2019 Intro to Graph Theory

    13/23

    No edges can be present in a condensationgraph of an ordinary graph.

    Two reasons: Edges have individual nodes as endpoints, not sets

    of nodes

    A possible edge would mean that nodes from twodifferent components are connected, thus in a

    path, thus in the same component.

    13

  • 8/13/2019 Intro to Graph Theory

    14/23

    A directed graph D = (V,E) consists of afinite set V = {n1,., nm} of nodes, and a setE = {e1, e2, ,ep}, where each edge ek =

    is an ordered pair of nodes.

    14

  • 8/13/2019 Intro to Graph Theory

    15/23

    15

    n1

    n7

    n3

    n5n4

    n2

    n6

    e1

    e4

    e5

    e3

    e2

  • 8/13/2019 Intro to Graph Theory

    16/23

    The in degree of a node in a directed graphis the number of distinct edges that havethe node as a terminal node.

    The out-degree of a node in a directedgraph is the number of distinct edges that

    have the node as a start point.

    16

  • 8/13/2019 Intro to Graph Theory

    17/23

    17

    The AMD of G=(V,E) with m nodes is anmm matrix where a(i,j) is a 1 if there is

    an edge from node i to node j, otherwiseit is 0 Row sum represents outdegrees

    Column sum represents indegrees

  • 8/13/2019 Intro to Graph Theory

    18/23

    18

    n1 n2 n3 n4 n5 n6 n7

    n1 0 1 0 1 0 0 0

    n2 0 0 0 0 1 0 0n3 0 0 0 1 0 0 0

    n4 0 0 0 0 0 1 0

    n5 0 0 0 0 0 0 0n6 0 0 0 0 0 0 0

    n7 0 0 0 0 0 0 0

  • 8/13/2019 Intro to Graph Theory

    19/23

    19

    Source node: a node with in-degreezero

    Sink node: a node with out-degree=0

    Transfer node: node with in-degree 0 and out-degree 0

  • 8/13/2019 Intro to Graph Theory

    20/23

    20

    Direction is important therefore Directed path (a sequence of edges eiand ej, the

    terminal node of eiis the initial node of ej)

    Cycle (directed path that begins and ends at thesame node)

    Directed semi-path (for adjacent pair of ei, the initial(terminal) node of the first edge is the initial(terminal) node of the second edge

    E.g., n1 and n3

  • 8/13/2019 Intro to Graph Theory

    21/23

    21

    n1 n2 n3 n4 n5 n6 n7

    n1 1 1 0 1 1 1 0

    n2 0 1 0 0 1 0 0n3 0 0 1 1 0 1 0

    n4 0 0 0 1 0 1 0

    n5 0 0 0 0 1 0 0n6 0 0 0 0 0 1 0

    n7 0 0 0 0 0 0 1

  • 8/13/2019 Intro to Graph Theory

    22/23

    22

    Connectedness of directed graph 0-connected (no path between ni, and nj)

    1-connected (semi-path between ni

    , and nj

    )

    2-connected(a path between ni, and nj )

    3-connected (a path between nito nj, and apathbetween nj, and ni)

    Strong components

  • 8/13/2019 Intro to Graph Theory

    23/23

    23

    n1

    n7

    n3

    n5n4

    n2

    n6

    e1

    e4

    e5

    e3

    e2

    e6

    n1 and n7 0-c

    n2 and n4 1-c

    n1 and n6 2-c

    n3 and n6 3-c