Docsity

Graphs - Computational Concepts in Biological Sciences - Lecture Note, Lecture notes of Computer Science

Toggle sidebar
bg1
Know the probability of a particular event =
# desirable outcomes ?
---------------------------------- = -----------------------------------
# total outcomes n!
1 precedes 2 : n!/2 cases in which 1 precedes 2,
a)
n!/2 cases in which 2 precedes 1
prob = (n!/2)/n! = 1/2
b)
1 immediately precedes 2
c)
12xxxxxxxx, x12xxxxxxx, …, xxxxxxxx12 (n-1 choices)
xxxxxxxxx P(n-2,n-2) = (n-2)!/0! = (n-2)!
n precedes 1 and n-1 precedes 2
Problem 8
Wednesday, November 17, 2010
3:00 PM
Graphs Page 1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d

Partial preview of the text

Download Graphs - Computational Concepts in Biological Sciences - Lecture Note and more Lecture notes Computer Science in PDF only on Docsity!

Know the probability of a particular event =

desirable outcomes?

---------------------------------- = -----------------------------------

total outcomes n!

a) 1 precedes 2 : n!/2 cases in which 1 precedes 2, n!/2 cases in which 2 precedes 1 prob = (n!/2)/n! = 1/ b) omitted c) 1 immediately precedes 2 12xxxxxxxx, x12xxxxxxx, …, xxxxxxxx12 (n-1 choices) xxxxxxxxx P(n-2,n-2) = (n-2)!/0! = (n-2)! n precedes 1 and n-1 precedes 2 Problem 8 Wednesday, November 17, 2010 3:00 PM Docsity.com

Docsity.com

represent vertices as circles represent edges as directed lines Graph drawing Example: task graph V = {"take out trash", "make dinner", "light candles", "shop for groceries", "finish work"} This is a partial order relation. The total order is an order in which you can complete the tasks! Graph drawing Wednesday, November 17, 2010 9:53 AM Docsity.com

Directed: edges have arrows Undirected: no arrows, used to depict symmetric relations Kinds of graphs An undirected graph is a symmetric relation! Kinds of graphs Wednesday, November 17, 2010 10:12 AM Docsity.com

A tree is just a graph where there is a unique path to each node, by walking edges. Kinds of undirected graphs Wednesday, November 17, 2010 10:28 AM Docsity.com

Distances between cities Friends/social networks Examples of graphs Wednesday, November 17, 2010 10:34 AM Docsity.com

Theorem: In a graph G=(V,E), the sum of all vertex degrees is 2 times the number of edges (|E|). Proof: each edge connects two vertices. Thus each edge is counted in the degrees of the two vertices it connects adding an edge adds two to the sum of all degrees. The handshaking theorem Wednesday, November 17, 2010 10:39 AM Docsity.com

Lemma: an undirected graph always has an even number of vertices of odd degree. the sum for V must be even, and the sum for Ve is even, so that the sum for Vo must be even also, but each degree of Vo is odd, Proof: Let G=(V,E) be an undirected graph. Split the vertices V into those with even degree Ve, and those with odd degree Vo. {Ve, Vo} is a partition of V. Then 2|E| is a sum of the degrees of Ve and the degrees of Vo. Thus so the only way the sum for Vo can be even is for Vo to have an even number of elements! Graphs are limited Wednesday, November 17, 2010 10:41 AM Docsity.com

An undirected graph G=(V,E) is bipartite if its vertices are separable into two sets V 1 and V 2 such that all edges go between V 1 and V 2. Bipartite graphs Wednesday, November 17, 2010 10:53 AM Docsity.com

Theorem: a graph is bipartite iff it is possible to color the vertices with two colors so that no two adjacent vertices have the same color. Proof: Without loss of generality let the colors be "red" and "blue". If G = (V,E) is bipartite, there is a partition V = V 1 U V 2 such that edges go between V 1 and V 2 but not within, so that coloring V 1 red and V 2 blue suffices. Conversely, if there is such a coloring, the red and blue vertices of the coloring constitute a partition of V. The coloring theorem Wednesday, November 17, 2010 10:57 AM Docsity.com

Same graph Wednesday, November 17, 2010 3:42 PM Docsity.com

A subgraph of a graph G=(V,E) is a graph G 2 =(V 2 ,E 2 ) with V 2 V and E 2 E. Often, we only need part of a graph to solve a problem. We can construct a subgraph by deleting specific vertices and/or edges. Given (V1,E1) and (V2,E2), how hard is it to determine whether (V1,E1) is a subgraph of (V2, E2)? Very hard! Subgraphs Wednesday, November 17, 2010 11:00 AM Docsity.com

An adjacency list for a vertex v is the set of vertices to which v is connected. In Perl, we represent sets as hashes. Thus we might code the following graph: as $g = { 'frank' => { 'george'=>1, 'sue'=>1}, 'george' => {'sue'=>1}, 'sue' => {} }; or even $g = { 'frank' => [ 'george', 'sue' ], 'george' => ['sue'], 'sue' => [] }; For undirected graphs, the adjacency lists are larger: might be represented as $g = { 'frank' => { 'george' => 1, 'sue' => 1 }, Adjacency lists Wednesday, November 17, 2010 11:04 AM Docsity.com

'frank' => { 'george' => 1, 'sue' => 1 }, 'george' => { 'frank' => 1 }, 'sue' => { 'frank' => 1 } }; or even $g = { 'frank' => [ 'george', 'sue' ], 'george' => [ 'frank' ], 'sue' => [ 'frank' ] }; Q: Why different kinds of lists? Hashes are faster, but take more space. Arrays are slower, but take less space. A: depends upon tradeoff between speed and size. Docsity.com