12
11/11/2011 1 Sesi 10 1 Graph (Contd) What makes a problem graph What makes a problem graph What makes a problem graph What makes a problem graph- - -like like like like? ? ? There are two components to a graph Nodes and edges In graph-like problems, these components have natural correspondences to problem elements Entities are nodes and interactions between entities are edges Most complex systems are graph-like 2 Friendship Network 3 Scientific collaboration network 4

Vemurafenib, the treatment of choice for patients with metastatic

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Vemurafenib, the treatment of choice for patients with metastatic

11/11/2011

1

Sesi 10

1

Graph (Contd)

What makes a problem graphWhat makes a problem graphWhat makes a problem graphWhat makes a problem graph----likelikelikelike????

� There are two components to a graph� Nodes and edges

� In graph-like problems, these components have natural correspondences to problem elements� Entities are nodes and interactions between entities are edges

� Most complex systems are graph-like

2

Friendship Network

3

Scientific collaboration network

4

Page 2: Vemurafenib, the treatment of choice for patients with metastatic

11/11/2011

2

Business ties in US biotechBusiness ties in US biotechBusiness ties in US biotechBusiness ties in US biotech----industryindustryindustryindustry

5

Genetic interaction network

6

Protein-Protein Interaction Networks

7

Transportation Networks

8

Page 3: Vemurafenib, the treatment of choice for patients with metastatic

11/11/2011

3

Internet

9

Ecological Networks

10

Structures and structural metricsStructures and structural metricsStructures and structural metricsStructures and structural metrics

� Graph structures are used to isolate interesting or important sections of a graph

� Structural metrics provide a measurement of a structural property of a graph� Global metrics refer to a whole graph

� Local metrics refer to a single node in a graph

11

Graph structuresGraph structuresGraph structuresGraph structures

� Identify interesting sections of a graph� Interesting because they form a significant domain-specific structure, or because they significantly contribute to graph properties

� A subset of the nodes and edges in a graph that possess certain characteristics, or relate to each other in particular ways

12

Page 4: Vemurafenib, the treatment of choice for patients with metastatic

11/11/2011

4

Connectivity & Connectivity & Connectivity & Connectivity & ComponentComponentComponentComponent

� A graph is connected if � you can get from any node to any other by following a sequence of edges OR

� any two nodes are connected by a path.

� A directed graph is strongly connected if there is a directed path from any node to any other node.

� Every disconnected graph can be split up into a number of connected components.

13

DegreeDegreeDegreeDegree� Undirected Graph

� Number of edges incident on a node

The degree of 5 is 3

� Directed Graph� In-degree: Number of edges entering

� Out-degree: Number of edges leaving

� Degree = indeg + outdeg

outdeg(1)=2indeg(1)=0

outdeg(2)=2indeg(2)=2

outdeg(3)=1indeg(3)=4

14

Degree: Simple FactsDegree: Simple FactsDegree: Simple FactsDegree: Simple Facts

� If G is a graph with m edges, then

Σ deg(v) = 2m = 2 |E |

� If G is a digraph then

Σ indeg(v)=Σ outdeg(v) = |E |

� Number of Odd degree Nodes is even

15

Walks, Cycle & PathWalks, Cycle & PathWalks, Cycle & PathWalks, Cycle & Path

� A walk of length k in a graph is a succession of k (not necessarily different) edges of the form

uv,vw,wx,…,yz.

� This walk is denote by uvwx…xz, and is referred to as a walk between u and z.

� A walk is closed is u=z �Closed Walks

� A cycle is a closed walk in which all the edges are different

� A path is a walk in which all the edges and all the nodes are different.

Walks, Cycle and Paths

1,2,5,2,3,4 1,2,5,2,3,2,1 1,2,3,4,6

walk of length 5 CW of length 6 path of length 4

16

1,2,5,1 2,3,4,5,2

3-cycle 4-cycle

Page 5: Vemurafenib, the treatment of choice for patients with metastatic

11/11/2011

5

Special Types of GraphsSpecial Types of GraphsSpecial Types of GraphsSpecial Types of Graphs

� Empty Graph / Edgeless graph�No edge

� Null graph�No nodes�Obviously no edge

17

Special GraphsSpecial GraphsSpecial GraphsSpecial Graphs

�Definition:The complete graph on n vertices, denoted by Kn, is the simple graph that contains exactly one edge between each pair of distinct vertices.

18

KK11 KK22 KK33 KK44 KK55

Special GraphsSpecial GraphsSpecial GraphsSpecial Graphs

�Definition:The cycle Cn, n ≥ 3, consists of n vertices v1, v2, …, vn and edges {v1, v2}, {v2, v3}, …, {vn-1, vn}, {vn, v1}.

19

CC33 CC44 CC55 CC66

Special GraphsSpecial GraphsSpecial GraphsSpecial Graphs

�Definition:We obtain the wheelWn when we add an additional vertex to the cycle Cn, for n ≥ 3, and connect this new vertex to each of the n vertices in Cn by adding new edges.

20

WW33 WW44 WW55 WW66

Page 6: Vemurafenib, the treatment of choice for patients with metastatic

11/11/2011

6

Special GraphsSpecial GraphsSpecial GraphsSpecial Graphs

�Definition:The n-cube, denoted by Qn, is the graph that has vertices representing the 2n bit strings of length n. Two vertices are adjacent if and only if the bit strings that they represent differ in exactly one bit position.

21

QQ11 QQ22 QQ33

00 110000 0101

11111010

000000 001001

101101100100

010010 011011

111111110110

Special GraphsSpecial GraphsSpecial GraphsSpecial Graphs

�Definition:A simple graph is called bipartite if its vertex set V can be partitioned into two disjoint nonempty sets V1 and V2 such that every edge in the graph connects a vertex in V1with a vertex in V2 (so that no edge in G connects either two vertices in V1 or two vertices in V2).

�For example, consider a graph that represents each person in a village by a vertex and each marriage by an edge.

�This graph is bipartite, because each edge connects a vertex in the subset of males with a vertex in the subset of females (if we think of traditional marriages).

22

23

Special GraphsSpecial GraphsSpecial GraphsSpecial Graphs

�Example I: Is C3 bipartite?

vv11

vv22 vv33

No, because there is no way to partition the vertices into two sets so that there are no edges with both endpoints in the same set.

•Example II: Is C6 bipartite?

vv55

vv11

vv22

vv33 vv44

vv66vv11 vv66

vv22vv55

vv33vv44

Yes, because we

can display C6 like

this:

Special GraphsSpecial GraphsSpecial GraphsSpecial Graphs

�Definition:The complete bipartite graph Km,n is the graph that has its vertex set partitioned into two subsets of m and n vertices, respectively. Two vertices are connected if and only if they are in different subsets.

24

KK3,23,2 KK3,43,4

Page 7: Vemurafenib, the treatment of choice for patients with metastatic

11/11/2011

7

TreesTreesTreesTrees

� Connected Acyclic Graph

� Two nodes have exactly one path between them

25

Representing GraphsRepresenting GraphsRepresenting GraphsRepresenting Graphs

X - 26

aa

bb

cc

dd

aa

bb

cc

dd

VertexAdjacent Vertices

a b, c, d

b a, d

c a, d

d a, b, c

Initial Vertex

Terminal Vertices

a c

b a

c

d a, b, c

Representing Graphs

An undirected graph and its adjacency matrix representation.

An undirected graph and its adjacency list representation.27

RepresentationRepresentationRepresentationRepresentation

�Matric� Incidence Matrix�V x E

� [vertex, edges] contains the edge's data

�Adjacency Matrix�V x V

� Boolean values (adjacent or not)

�Or Edge Weights28

� List

�Edge List� pairs (ordered if directed) of vertices

�Optionally weight and other data

�Adjacency List (node list)

Page 8: Vemurafenib, the treatment of choice for patients with metastatic

11/11/2011

8

Representation (Matrix)Representation (Matrix)Representation (Matrix)Representation (Matrix)� Incidence Matrix

� Adjacency Matrix

29

DegreeDegreeDegreeDegree� Untuk graf tak-berarah,

d(vi) =

� Untuk graf berarah,� din (vj) = jumlah nilai pada kolom j =

� dout (vi) = jumlah nilai pada baris i =

30

∑=

n

j

ija

1

∑=

n

i

ija

1

∑=

n

j

ija

1

Graph A

Matrix Graph A

Degree Graph A ???

Topological DistanceTopological DistanceTopological DistanceTopological DistanceA shortest path is the minimum path connecting two

nodes.

The number of edges in the shortest path connecting p

and q is the topological distance between these two

nodes, dp,q

Distance Matrix

|V | x |V | matrix D = ( dij ) such that dij is the topological

distance between i and j.

31 0212336

2012115

1101224

2210123

3121012

3122101

654321

07.05.01.20

7.001.200

5.01.204.30

004.305.1

0005.10

E

D

C

B

A

EDCBA

Adjacency Matrix of Weighted graphs

32

Page 9: Vemurafenib, the treatment of choice for patients with metastatic

11/11/2011

9

02140

20100

11030

40301

00012

E

D

C

B

A

EDCBA

Adjacency Matrix of Multigraphs

01000

10100

10010

20010

00010

E

D

C

B

A

EDCBA

Undirected

Graph

Directed

Graph

33

Representation Representation Representation Representation (List)(List)(List)(List)

� Adjacency-list representation

� an array of |V | lists, one for each vertex in V.

� For each u ∈ V , ADJ [ u ] points to all its adjacent vertices.

� Edge and Node Lists

34

Edge List

1 2

1 2

2 3

2 5

3 3

4 3

4 5

5 3

5 4

Node List

1 2 2

2 3 5

3 3

4 3 5

5 3 4

Edge List

1 2 1.2

2 4 0.2

4 5 0.3

4 1 0.5

5 4 0.5

6 3 1.5

Edge Lists for Weighted Graphs

35

List Representation

36

•Vertex File

•Edge File

Page 10: Vemurafenib, the treatment of choice for patients with metastatic

11/11/2011

10

Operations on GraphsOperations on GraphsOperations on GraphsOperations on Graphs

�Definition:A subgraph of a graph G = (V, E) is a graph H = (W, F) where W⊆V and F⊆E.

�Note:Of course, H is a valid graph, so we cannot remove any endpoints of remaining edges when creating H.

�Example:

37

KK55 subgraph of Ksubgraph of K55

Operations on GraphsOperations on GraphsOperations on GraphsOperations on Graphs

�Definition:The union of two simple graphs G1 = (V1, E1) and G2 = (V2, E2) is the simple graph with vertex set V1

∪V2 and edge set E1 ∪ E2.

�The union of G1 and G2 is denoted by G1 ∪∪∪∪ G2.

38

GG11 GG22 GG1 1 ∪∪ GG2 2 = K= K55

Isomorphism of GraphsIsomorphism of GraphsIsomorphism of GraphsIsomorphism of Graphs

39

�Definition:The simple graphs G1 = (V1, E1) and G2 = (V2, E2) are isomorphic if there is a bijection (an one-to-one and onto function) f from V1 to V2 with the property that a and b are adjacent in G1 if and only if f(a) and f(b) are adjacent in G2, for all a and b in V1.

�Such a function f is called an isomorphism.

�In other words, G1 and G2 are isomorphic if their vertices can be ordered in such a way that the adjacency matrices MG1

and MG2are identical.

�From a visual standpoint, G1 and G2 are isomorphic if they can be arranged in such a way that their displays are identical (of course without changing adjacency).

�Unfortunately, for two simple graphs, each with n vertices, there are n! possible isomorphisms that we have to check in order to show that these graphs are isomorphic.

�However, showing that two graphs are not isomorphic can be easy.

Isomorphism of GraphsIsomorphism of GraphsIsomorphism of GraphsIsomorphism of Graphs

�For this purpose we can check invariants, that is, properties that two isomorphic simple graphs must both have.

�For example, they must have

� the same number of vertices,

� the same number of edges, and

� the same degrees of vertices.

�Note that two graphs that differ in any of these invariants are not isomorphic, but two graphs that match in all of them are not necessarily isomorphic.

40

Page 11: Vemurafenib, the treatment of choice for patients with metastatic

11/11/2011

11

Isomorphism of GraphsIsomorphism of GraphsIsomorphism of GraphsIsomorphism of Graphs

�Example I:Are the following two graphs isomorphic?

�Solution:Yes, they are isomorphic, because they can be arranged to look identical. You can see this if in the right graph you move vertex b to the left of the edge {a, c}. Then the isomorphism f from the left to the right graph is: f(a) = e, f(b) = a, f(c) = b, f(d) = c, f(e) = d.

41

dd

aa

bb

cc

ee

dd

aa

bb

cc

ee

Isomorphism of GraphsIsomorphism of GraphsIsomorphism of GraphsIsomorphism of Graphs

�Example II: How about these two graphs?

� Solution: No, they are not isomorphic, because they differ in the degrees of their vertices. Vertex d in right graph is of degree one, but there is no such vertex in the left graph.

42

dd

aa

bb

cc

ee

dd

aa

bb

cc

ee

Isomorphism of GraphsIsomorphism of GraphsIsomorphism of GraphsIsomorphism of Graphs

�Example III: How about these two graphs?

� Solution:Yes.

Coz AG1=AG2

43

Isomorphism of GraphsIsomorphism of GraphsIsomorphism of GraphsIsomorphism of Graphs

�Example IV: How about these graphs?

44

Page 12: Vemurafenib, the treatment of choice for patients with metastatic

11/11/2011

12

Graf Planar (Planar Graph) & Graf Planar (Planar Graph) & Graf Planar (Planar Graph) & Graf Planar (Planar Graph) &

Graf Graf Graf Graf BidangBidangBidangBidang (Plane Graph)(Plane Graph)(Plane Graph)(Plane Graph)� Graf Planar (Planar Graph) : Graf yang dapat digambarkan padabidang datar dengan sisi-sisi tidak saling memotong

� Graf bidang (plane graph) : Graf planar yang digambarkan dengansisi-sisi yang tidak saling berpotongan

� Manakah Grapf-graf berikut ini yang termasuk graf planar dan/atau graf bidang?

45

H2 H3

W G E

H2 H3

W G E

H1H1

R1

R2

R3

R5

R4

R6

ReferensiReferensiReferensiReferensi1. Ernesto Estrada, “Introduction to Network Theory: Basic

Concepts”, Institute of Complex Systems at StrathclydeDepartment of Mathematics, Department of Physics, 2010

2. Dr. Djamel Bouchaffra, “CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 1): Graphs”

3. Y. Peng, “Graph”, University of Maryland4. Rinaldi Munir, “Materi Kuliah Matematika Diskrit”,Informatika-

ITB, Bandung,20035. Rinaldi Munir, “Matematika Diskrit”,Informatika,

Bandung,2001

46