Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Informatique pour la physique : thorie des graphes M1 thorie des systmes complexes Politecnico Di Torino

Robin Nicole April 10, 2012

Contents
1 Denitions 2 Thormes 3 Trees 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 few notions about tree theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Graph representation 4.1 Adjacency matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 Laplacian matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Graph caracterization 5.1 Independent set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2 Clique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Graph coloring 7 Planar graph 8 Algorithms on graphs 8.1 Reachability . . . . . . . 8.2 Exercises . . . . . . . . 8.3 Convert BFS to Shortest 8.4 Maximum ow problem 2 2 3 3 4 4 4 4 5 5 5 6 7 7 7 8 8 9

. . . . . . path . . .

. . . . . . . . . . . . algorithm . . . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

what is an algorithmic procedure recursive functions Turing-machine calculus All those technics are equivalent. Any function than can be computed, can be computed using a Turing machine.

Informatique pour la physique - M1

Denitions

digraph G = (V, E V V ) v V vortices (v, w) E edges (v, w) = (w, v) graph G = (V, E [V V ]) Ai,j = 1 (vi , vj ) E 0 if (vi , vj ) E

Adjacency matrix for a graph Ai,j = Aj,i deegree of a vertex Thorme


v

d(v) = #{w V |(v, w) E}

d(v) is even Graph where d(v) = constante P () =


#{v:d(v)=} |v|

Regular graph

Degree distribution P (d) = (d, d)

Neighborhood v(i) = i = {j : (i, j) E} Walk generic sequence : W = (v1 , v2 , ..., vk ) where (vi , vi+1 ) E length l(w) = K 1 Path is a walk where (vi , vi+1 ) = (vj , vj+1 )i, j ( no repetition for edges ) Simple path is a path such that vi = vj i, j (no vertex repetition) Circuit Circuit is a closed simple path vi = vk

Thormes
given G = (V, E) let P be the shortest walk between v1 and v2 hence P is a simple path

Thorme 1

Thorme 2 given G = (V, E) suppose d(v) 2 v V hence G has a cycle PROOF faite dans le cours dinfo : suppose d(v) 2 and G has no cycles 1. take a simple path P = (v1 , v2 , ..., vk ) K 2 2. take vk+1 v k {vk1 }, take vk+1 = vi 3. P P = (v1 , ..., vk , vk+1 , vk ) hence by induction P 2

Informatique pour la physique - M1

Complete graph

G = (V,E) where (i, j) E i = j |E(Kn )| =

n(n1) 2

Connected graph G is connected i, j V Here exist a walk/path P = (i, ..., j) Connected components Gi is connected Gi Gj = E(Gi ) E(Gj ) = V (Gi ) V (Gj ) = Bipartite graph G = (V = A d B, E = A B) where d is the dsjoint union G = G1 G2 ... Gn such that

Thorme G is bipartite G has no odd cycles PROOF 2 No od cycles implies BP lets assume that G is connected, take v V we dene A = {w V : P = (v = v1 , ..., vk = w)kodd} and B = the same with k even we want to prove 1. A B = 2. A B = V 3. there is no edges wihin A or B lets prove 1 : suppose w A B we have : (v = v1 , ..., vk1 = w) with k1 odd (v = v1 , ..., vk2 = w) with k2 even

3
3.1

Trees
Introduction

Trees helped to build an Ising model.

Dnition T (V, E)

Figure 1: scheme of a tree, 1, 2, 3 are the leafs and 6 is the root 1. Unique path between each pair of vertex 2. adding one edge create a cycle

Informatique pour la physique - M1

3. removing one edge disconnect the tree 4. every tree with at leas two vertexs has at least two leaves Those properties are equivalent : 1. G is connected and acyclic 2. G is maximally acyclic i.e. (V, E {e} not acyclic for e E 3. G is minimally connected (V, E {e}) not connected for e E 4. G is a tree (G T ) Trouver la demo sur internet ou dans les notes

3.2

few notions about tree theory

isomorphism Given two graphs G1 andG2 with two dierent labels ? G1 and G2 are isomorphic if there exist a function that turns the vertex of one graph into the vertex of the other. Theoreme induction G = (V,E) has at least |V | |E| connected components. Proof can d=be found by

Dnition : distance the distance between two points is the minimal lenghth of a path between two points. The maximum of the distance in a graph is called the diameter of a graph

4
4.1

Graph representation
Adjacency matrix

Theoreme: power of A What can we learn from A the adjacency matrix : (Ak )i,j number of walks of length k starting in a and ending in j. PROOF (Ak )i,j = i1 ,i2 ,...,ik1 = Aii1 Ai1 i2 ...Aik1 ik 1. 2. 3.
i i

i = tr(A) = 0

2 = tr(A2 ) = 2|E| = # of closed walks of length 2 starting and ending in the same i vertex
i

n = n!#(n) i

4. #(n) = Idt Ak Id 5. for K 1 #(k) k n

4.2

Laplacian matrix
Ai,j = Di =
j

Dnition

wi,j if (i, j) E 0 if (i, j) E Ai,j Di,i

where i,j is the degree of (i, j)

Dnition: laplacian matrix

L D A is the Laplacian matrix

Informatique pour la physique - M1

Remarque Peut etre revoir les notions sur les matrices symtriques let G = (V, E, W ) where w : R+ we can dene an adjacency matrix Ai,j = wi,j if (i, j) E 0 if (i, j) E

and we can dene the degree of an odd as Di = j Ai,j with L D A we obtain this quadratic form on F : X T LX = (i,j)E wi,j (Xi Xj )2 Let use L to study connectivity : xi = ii x = (x, x, ..., x, x) hence we have X T LX LX = 0 = o is an eigenvalue

Thorme G = (V, E) and 0 = 1 2 ... n hence if 2 > 0 G is connected PROOF prove that if G is disconnected then 2 = 0 G is disconnected G = G1 G2 then : L= L1 L2

Where L1 , L2 are Laplacian matrix. this matrix has two eigenvectors that are lineary independant and have 0 for eigenvalue.

5
5.1

Graph caracterization
Independent set

S V is an independent set if no edge in G has both its endpoint and start point in S

Figure 2: Point in red an independent set

Dnition : t-partite graph G = (V,E) where V = V1 V2 ...Vt where V1 , V2 , ..., Vt are independent set

5.2

Clique

C G where C is fully connected 5

Informatique pour la physique - M1

Figure 3: In red this is a clique

Graph coloring
c : V {1, 2, ..., k}

Dnition : K-coloring where c(v) is the color of the vertex v ki = set of vertices of color "i" |ki | # of vertices od color i C is a proper coloring if K1 , K2 , ...Kk are independent sets i.e., adjacent vertices v, w have c(v) = c(w)

Figure 4: a proper coloured graph G is k-colorable if it has a k-coloring Dnition : chromatic number The chromatic number of a graph is (G) = min{k : G is k-colorable}
Th : (G) max{cl(G), (G) } where

cl(G) = size of maximum clique (G) = maximum size of an independent set in G =


k i=1

|ki |

Informatique pour la physique - M1

PROOF if C is a clique hence every vertex of c must have a dierent color in a proper coloring if k1 , ..., kk dene a proper coloring hence = |ki | k(G) hence k (G)

Planar graph

Denition G(V, E) is planar if it can be drawn on the plane without crossing edges. Dnition : faces regions of the plane such that X, Y S can be joined by a curve that does not meet any edge

Figure 5: Example of a planar graph with 4 faces

Euler formula = |v| = |E|

let G(V,E) be a planar graph :

= # faces we have the Euler formula +=2 PROOF by induction over nu for = 1 we have = + 1 if > 1 we ha ve an edge e which is not a loop hence we contract e and create a graph G.e the new graph is still connected (G.e) = (G) (G.e) = (G) 1 (G) = (G) 1

8
8.1

Algorithms on graphs
Reachability

Problem Given an oriented graph G(V, E) and given two nodes 1 and n is there a path that go from 1 to n ? 1. initialy S = {1} 2. node can be marked or unmarked 3. a node is marked if it has been in S at a point of the past 4. initialy only 1 is marked

Informatique pour la physique - M1

5. begin of the loop : (a) we chose one node from S and remove it (b) we then process all (i,j) out of i (c) if j is unmarked we mark it and put it on S (d) the process continue until S is empty 6. answer : yes if n is marked no if n is unmarked

That was an example of the Breadth First Search (BFS) begin with a root explore neighbourn for each neighbourn explore the unexplored neighbourn etc... Complexity of the algorithm each vertex is visited once for each vertex we spend at most n operations in processing edges to neighbourn nodes Assuming that all other operations can be processed in nite time hence complexity C(N ) = O(N 2 )

8.2

Exercises
let G(V, E) a graph and B a |V | |E| matrix dened by -1 if edge e leaves vertex e 1 if edge e enter into vertex i Bi,e = 0 if else

Exercise 1

What is BB T ? Probleme Show that determining wether a directed graph contains a universal sinh (i.e. a vertex of degree |V | 1 ) can be compute in a time O(|V |) given the adjacency matrix. Une solution nave en O(|V |2 ) est : Pour i allant de 1 a |V| faire S =
j

Aij

ds que S est gal |V| - 1 on arrete lalgorithme et on retourne vrai si par contre au bout de |V| ittrations on a toujours pas retourn true alors on retourne faux.

8.3

Convert BFS to Shortest path algorithm

How can we modify BFS in order to nd the shortest path ? If at each stap we choose he node that has stayed in S hence the shortest path is found

Informatique pour la physique - M1

Example nd the shortest path between 1 and 5 1. S = 1 2. S = 2 | 4 3. S = 3 | 2 4. S = 5 | 3 5. S = 5 6. S = At each step we take node i and we put an arrow that point on the node we are condiderating. After, to fnd the shortest path we just have to follow he arrows from the nal point of our path.

8.4

Maximum ow problem

Let say that we have a graph each tube has a maximum capacity. We want to know for each f the value of the waer ow we put in the tube in order to have the maximum water ow. let G =

Figure 6: Maximum ow problem N = (V,E) C : E R+ maximum of ow hat can pass through an edge. C(u,v) = 0 if (u,v) E Dnition : ow f : E R such that

1. fuv f (u, v) Cuv 2. fuv = fvu 3.


wV

fu,w = 0 unless u = s or u = t

Dnition : ow outgoing S |f | wV f (s, w) ow injeced in the network a A, b Bf (a, b), Total ow between two sets If we have two graph A and B f (A, B) = f (A, A) = 0 Prop f (s, V ) = f (t, V ) Proof we know that 0 = f (V, V ) = f (s, V ) + f (t, V ) + exit so the is O due to (2) Dnition : cut

vV {s,t}

f (u, v) what enter has to

a cut is a partition of V such as V = S d T with s S, t T and S T =

Def : capacity of a cut C(S, T ) uS,vT c(u, v) The problem is to nd the minimum cut : the MIN-CUT PROBLEM 9

Informatique pour la physique - M1

Prop Take a path betwen S and T P = (P1 = s, ..., PK = t) c = mint=1..k1 (c(Pt , Pt+1 ) cif (u, v) = (Pt , Pt+1 ) cif (u, v) = (Pt+1 , Pt ) fu,v = 0else then 1. f is a ow 2. || = c Prop : (S,T) is a cut f(S,T) = |f|

Prop : f ow cut (S,T) |f| = f (S, T ) C(S, T ) Def : Residual capacity Given a ow f, the residual capacity cf is cf (u, v) c(u, v) f (u, v) Given fuv cuv cf (u, v 0 Th : MIN CUT | MAX FLOW if f is the maximum ow and (S , T ) is the maximum cut then |f | = c(S , T )

10

You might also like