1 Intro. to Graph Theory BIO/CS 471 – Algorithms for bioinformatics Graph Theoretic Concepts and Algorithms for Bioinformatics.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

Chapter 9 Graphs.
22C:19 Discrete Math Graphs Fall 2010 Sukumar Ghosh.
22C:19 Discrete Math Graphs Fall 2014 Sukumar Ghosh.
Graph Theory.
PSU CS Algorithms Analysis and Design Graphs.
TECH Computer Science Graphs and Graph Traversals  // From Tree to Graph  // Many programs can be cast as problems on graph Definitions and Representations.
Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Chapter 8, Part I Graph Algorithms.
Introduction This chapter explores graphs and their applications in computer science This chapter explores graphs and their applications in computer science.
Data Structures Using C++
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part R5. Graphs.
Graph & BFS.
© 2006 Pearson Addison-Wesley. All rights reserved14 A-1 Chapter 14 Graphs.
CS 311 Graph Algorithms. Definitions A Graph G = (V, E) where V is a set of vertices and E is a set of edges, An edge is a pair (u,v) where u,v  V. If.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
Introduction to Graphs
Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
Discrete Mathematics Lecture 9 Alexander Bukharovich New York University.
22C:19 Discrete Math Graphs Spring 2014 Sukumar Ghosh.
Social Media Mining Graph Essentials.
GRAPH Learning Outcomes Students should be able to:
IS 2610: Data Structures Graph April 5, 2004.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Graph Theoretic Concepts. What is a graph? A set of vertices (or nodes) linked by edges Mathematically, we often write G = (V,E)  V: set of vertices,
Chapter 2 Graph Algorithms.
Graph Theory Topics to be covered:
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
Chapter 14 Graphs. © 2004 Pearson Addison-Wesley. All rights reserved Terminology G = {V, E} A graph G consists of two sets –A set V of vertices,
1 ELEC692 Fall 2004 Lecture 1b ELEC692 Lecture 1a Introduction to graph theory and algorithm.
Foundations of Discrete Mathematics
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Euler paths and tours.
1 CS104 : Discrete Structures Chapter V Graph Theory.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Week 11 - Monday.  What did we talk about last time?  Binomial theorem and Pascal's triangle  Conditional probability  Bayes’ theorem.
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Data Structures & Algorithms Graphs
Basic Notions on Graphs. The House-and-Utilities Problem.
Most of contents are provided by the website Graph Essentials TJTSD66: Advanced Topics in Social Media.
Chapter 5 Graphs  the puzzle of the seven bridge in the Königsberg,  on the Pregel.
1 Graphs Theory UNIT IV. 2Contents  Basic terminology,  Multi graphs and weighted graphs  Paths and circuits  Shortest path in weighted graph  Hamiltonian.
Graphs A ‘Graph’ is a diagram that shows how things are connected together. It makes no attempt to draw actual paths or routes and scale is generally inconsequential.
Graph Theory and Applications
Introduction to Graph Theory
Graphs. Graphs Similar to the graphs you’ve known since the 5 th grade: line graphs, bar graphs, etc., but more general. Those mathematical graphs are.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
GRAPHS. Graph Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component, spanning tree Types of graphs: undirected,
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Discrete Structures CISC 2315 FALL 2010 Graphs & Trees.
Graphs Upon completion you will be able to:
Chapter 9: Graphs.
Introduction to Graph Theory By: Arun Kumar (Asst. Professor) (Asst. Professor)
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Chapter 05 Introduction to Graph And Search Algorithms.
Graphs. Graph Definitions A graph G is denoted by G = (V, E) where  V is the set of vertices or nodes of the graph  E is the set of edges or arcs connecting.
Graph Theory Graph Theory - History Leonhard Euler's paper on “Seven Bridges of Königsberg”, published in 1736.
Data Structures and Algorithm Analysis Graph Algorithms Lecturer: Jing Liu Homepage:
Graphs Rosen, Chapter 8. NOT ONE OF THESE! One of these!
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
1 GRAPHS – Definitions A graph G = (V, E) consists of –a set of vertices, V, and –a set of edges, E, where each edge is a pair (v,w) s.t. v,w  V Vertices.
Lecture 20. Graphs and network models 1. Recap Binary search tree is a special binary tree which is designed to make the search of elements or keys in.
1 Data Structures and Algorithms Graphs. 2 Graphs Basic Definitions Paths and Cycles Connectivity Other Properties Representation Examples of Graph Algorithms:
Leda Demos By: Kelley Louie Credits: definitions from Algorithms Lectures and Discrete Mathematics with Algorithms by Albertson and Hutchinson graphics.
Chapter 5 : Trees.
Graph theory Definitions Trees, cycles, directed graphs.
Graphs Chapter 13.
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Presentation transcript:

1 Intro. to Graph Theory BIO/CS 471 – Algorithms for bioinformatics Graph Theoretic Concepts and Algorithms for Bioinformatics

2 Intro. to Graph Theory What is a “graph” Formally: A finite graph G(V, E) is a pair (V, E), where V is a finite set and E is a binary relation on V. –Recall: A relation R between two sets X and Y is a subset of X x Y. –For each selection of two distinct V’s, that pair of V’s is either in set E or not in set E. The elements of the set V are called vertices (or nodes) and those of set E are called edges. Undirected graph: The edges are unordered pairs of V (i.e. the binary relation is symmetric). –Ex: undirected G(V,E); V = {a,b,c}, E = {{a,b}, {b,c}} Directed graph (digraph):The edges are ordered pairs of V (i.e. the binary relation is not necessarily symmetric). –Ex: digraph G(V,E); V = {a,b,c}, E = {(a,b), (b,c)} a b c a b c

3 Intro. to Graph Theory Why graphs? Many problems can be stated in terms of a graph The properties of graphs are well-studied –Many algorithms exists to solve problems posed as graphs –Many problems are already known to be intractable By reducing an instance of a problem to a standard graph problem, we may be able to use well-known graph algorithms to provide an optimal solution Graphs are excellent structures for storing, searching, and retrieving large amounts of data –Graph theoretic techniques play an important role in increasing the storage/search efficiency of computational techniques. Graphs are covered in section 2.2 of Setubal & Meidanis

4 Intro. to Graph Theory Graphs in bioinformatics Sequences –DNA, proteins, etc. Chemical compounds Metabolic pathways RYLI

5 Intro. to Graph Theory Graphs in bioinformatics Phylogenetic trees

6 Intro. to Graph Theory Basic definitions incidence: an edge (directed or undirected) is incident to a vertex that is one of its end points. degree of a vertex: number of edges incident to it –Nodes of a digraph can also be said to have an indegree and an outdegree adjacency: two vertices connected by an edge are adjacent Undirected graph Directed graph isolated vertex loop multiple edges G=(V,E) adjacent loop

7 Intro. to Graph Theory xy path: no vertex can be repeated example path: a-b-c-d-e trail: no edge can be repeated example trail: a-b-c-d-e-b-d walk: no restriction example walk: a-b-d-a-b-c closed: if starting vertex is also ending vertex length: number of edges in the path, trail, or walk circuit: a closed trail (ex: a-b-c-d-b-e-d-a) cycle: closed path (ex: a-b-c-d-a) a b c d e “Travel” in graphs

8 Intro. to Graph Theory Types of graphs simple graph: an undirected graph with no loops or multiple edges between the same two vertices multi-graph: any graph that is not simple connected graph: all vertex pairs are joined by a path disconnected graph: at least one vertex pairs is not joined by a path complete graph: all vertex pairs are adjacent –K n : the completely connected graph with n vertices Simple graph a b c d e K5K5 a b c d e Disconnected graph with two components

9 Intro. to Graph Theory Types of graphs acyclic graph (forest): a graph with no cycles tree: a connected, acyclic graph rooted tree: a tree with a “root” or “distinguished” vertex –leaves: the terminal nodes of a rooted tree directed acyclic graph (DAG): a digraph with no cycles weighted graph: any graph with weights associated with the edges (edge- weighted) and/or the vertices (vertex-weighted) b a c d ef

10 Intro. to Graph Theory Digraph definitions for digraphs only… Every edge has a head (starting point) and a tail (ending point) Walks, trails, and paths can only use edges in the appropriate direction In a DAG, every path connects an predecessor/ancestor (the vertex at the head of the path) to its successor/descendents (nodes at the tail of any path). parent: direct ancestor (one hop) child: direct descendent (one hop) A descendent vertex is reachable from any of its ancestors vertices Directed graph a b c d x y z w u v

11 Intro. to Graph Theory Computer representation undirected graphs: usually represented as digraphs with two directed edges per “actual” undirected edge. adjacency matrix: a |V| x |V| array where each cell i,j contains the weight of the edge between v i and v j (or 0 for no edge) adjacency list: a |V| array where each cell i contains a list of all vertices adjacent to v i incidence matrix: a |V| by |E| array where each cell i,j contains a weight (or a defined constant HEAD for unweighted graphs) if the vertex i is the head of edge j or a constant TAIL if vertex I is the tail of edge j cb ad adjacency matrix adjacency list incidence matrix

12 Intro. to Graph Theory Computer representation Linked list of nodes: Node is a defined data object with labels which include a list of pointers to its children and/or parents Graph = [] # list of nodes Class Node: label = NIL; parents = []; # list of nodes coming into this node children = []; # list of nodes coming out of this node childEdgeWeights = []; # ordered list of edged weights

13 Intro. to Graph Theory G’(V’,E’) is a subgraph of G(V,E) if V’  V and E’  E. induced subgraph: a subgraph that contains all possible edges in E that have end points of the vertices of the selected V’ Subgraphs a b c d e b c d e a c d G(V,E)G’({a,c,d},{{c,d}}) Induced subgraph of G with V’ = {b,c,d,e}

14 Intro. to Graph Theory The complement of a graph G (V,E) is a graph with the same vertex set, but with vertices adjacent only if they were not adjacent in G(V,E) Complement of a graph a b c d e G a b c d e

15 Intro. to Graph Theory Consider a weighted connected directed graph with a distinguished vertex source: a distinguished vertex with zero in-degree What is the path of total minimum weight from the source to any other vertex? Greedy strategy works for simple problems (no cycles, no negative weights) Longest path is a similar problem (complement weights) We will see this again soon for fragment assembly! Famous problems: Shortest path cb ad

16 Intro. to Graph Theory Dijkstra’s Algorithm D(x) = distance from s to x (initially all  ) 1.Select the closest vertex to s, according to the current estimate (call it c) 2.Recompute the estimate for every other vertex, x, as the MINIMUM of: 1.The current distance, or 2.The distance from s to c, plus the distance from c to x – D(c) + W(c, x)

17 Intro. to Graph Theory Dijkstra’s Algorithm Example ABCDE Initial0  Process A  Process C Process B Process D Process E A B CE D

18 Intro. to Graph Theory Two graphs are isomorphic if a 1-to-1 correspondence between their vertex sets exists that preserve adjacencies Determining to two graphs are isomorphic is NP-complete Famous problems: Isomorphism a b c d e

19 Intro. to Graph Theory Famous problems: Maximal clique clique: a complete subgraph maximal clique: a clique not contained in any other clique; the largest complete subgraph in the graph Vertex cover: a subset of vertices such that each edge in E has at least one end-point in the subset clique cover: vertex set divided into non-disjoint subsets, each of which induces a clique clique partition: a disjoint clique cover Maximal cliques: {1,2,3},{1,3,4} Vertex cover: {1,3} Clique cover: { {1,2,3}{1,3,4} } Clique partition: { {1,2,3}{4} }

20 Intro. to Graph Theory Famous problems: Coloring vertex coloring: labeling the vertices such that no edge in E has two end- points with the same label chromatic number: the smallest number of labels for a coloring of a graph What is the chromatic number of this graph? Would you believe that this problem (in general) is intractable? 12 43

21 Intro. to Graph Theory Famous problems: Hamilton & TSP Hamiltonian path: a path through a graph which contains every vertex exactly once Finding a Hamiltonian path is another NP-complete problem… Traveling Salesmen Problem (TSP): find a Hamiltonian path of minimum cost ab c d e f g h i a b c d e

22 Intro. to Graph Theory Famous problems: Bipartite graphs Bipartite: any graph whose vertices can be partitioned into two distinct sets so that every edge has one endpoint in each set. How colorable is a bipartite graph? Can you come up with an algorithm to determine if a graph is bipartite or not? Is this problem tractable or intractable? K 4,4

23 Intro. to Graph Theory Famous problems: Minimal cut set cut set: a subset of edges whose remove causes the number of graph components to increase vertex separation set: a subset of vertices whose removal causes the number of graph components to increase How would you determine the minimal cut set or vertex separation set? a b c d e f g h cut-sets: {(a,b),(a,c)}, {(b,d),(c,d)},{(d,f)},...

24 Intro. to Graph Theory Famous problem: Conflict graphs Conflict graph: a graph where each vertex represents a concept or resource and an edge between two vertices represents a conflict between these two concepts When the vertices represents intervals on the real line (such as time) the conflict graph is sometimes called an interval graph A coloring of an interval graph produces a schedule that shows how to best resolve the conflicts… a minimal coloring is the “best” schedule” This concept is used to solve problems in the physical mapping of DNA ab c fe d Colors?

25 Intro. to Graph Theory Famous problems: Spanning tree spanning tree: A subset of edges that are sufficient to keep a graph connected if all other edges are removed minimum spanning tree: A spanning tree where the sum of the edge weights is minimum a b c d e f g h a b c d e f g h

26 Intro. to Graph Theory G is said to have a Euler circuit if there is a circuit in G that traverses every edge in the graph exactly once The seven bridges of Konigsberg: Find a way to walk about the city so as to cross each bridge exactly once and then return to the starting point. Famous problems: Euler circuit area barea d area c b c d a This one is in P!

27 Intro. to Graph Theory Famous problems: Dictionary How can we organize a dictionary for fast lookup? abcyz … abcyz … abcyz … abcyz … abcyz … abcyz … “CAB” 26-ary “trie”

28 Intro. to Graph Theory Graph traversal There are many strategies for solving graph problems… for many problems, the efficiency and accuracy of the solution boil down to how you “search” the graph. We will consider a “travel” problem for example: Given the graph below, find a path from vertex a to vertex d. Shorter paths (in terms of edge weight sums) are desirable. b e a d f c

29 Intro. to Graph Theory A greedy approach greedy traversal: Starting with the “root” node, take the edge with smallest weight. Mark the edge so that you never attempt to use it again. If you get to the end, great! If you get to a dead end, back up one decision and try the next best edge. Advantages: Fast! Drawbacks: Answer is usually non-optimal For some problems, greedy approaches are optimal, for others the answer may usually be close to the best answers, for yet other problems, the greedy strategy is a poor choice. b e a d f c Start node: a End node: d Traversal order: a, c, f, e, b, d

30 Intro. to Graph Theory Exhaustive search: Breadth-first For the current node, do any necessary work –In this case, calculate the cost to get to the node by the current path; if the cost is better than any previous path, update the “best path” and “lowest cost”. Place all adjacent unused edges in a queue (FIFO) Take an edge from the queue, mark it as used, and follow it to the new current node b e a d f c Traversal order: a, b, c, d, e, f

31 Intro. to Graph Theory Exhaustive search: Depth-first For each current node –do any necessary work –Pick one unused edge out and follow it to a new current node –If no unused edges exist, unmark all of your edges an go back from whence you came! b e a d f c Traversal order: a, b, d, e, f, c DFS (G, v) V.state = “visited” Process vertex v Foreach edge (v,w) { if w.state = “unseen” { DFS (G, w) process edge (v,w) }

32 Intro. to Graph Theory Branch and Bound Begin a depth-first search (DFS) Once you achieve a successful result, note the result as our initial “best result” Continue the DFS; if you find a better result, update the “best result” At each step of the DFS compare your current “cost” to the cost of the current “best result”; if we already exceed the cost of the best result, stop the downward search! Mark all edges as used, and head back up. b e a d f c Path Current Best ACF711 ACFE1511 < prune AB311 ABD88 ABE78 ABEF 148 Traversal order: Path Current Best A0- AE2- AEB6- AEBD1111 AEF 911 AEFC 1511 AC111

33 Intro. to Graph Theory Binary search trees Binary trees have at two children per node (the child may be null) Binary search trees are organized so that each node has a label. When searching or inserting a value, compare the target value to each node; one out-going edge corresponds to “less than” and one out-going edge corresponds to “greater than”. On the average, you eliminate 50% of the search space per node… if the tree is balanced