The Extended Longest Path Problem

Total Page:16

File Type:pdf, Size:1020Kb

The Extended Longest Path Problem The Extended Longest Path Problem (Nov 2009, Theory seminar) Problem definion Longest Path Problem: Given an undirected graph, G = (V,E) and an integer k ≥ 0, does G have a simple path of length k? Extended Longest Path Problem: Given an undirected graph, G = (V,E) and an integer k ≥ 0, find all pairs of verces that have a simple path of length k between them. (Note: 1. “length k” denotes edge‐length k (i.e. a simple path of length k has k edges. 2. The Longest Path Problem, and the Extended Longest Path Problem – both are NP‐complete. ) • This talk will be based on the following two papers: [1] Color‐coding: Alon, Yuster, Zwick. [1995] [2] Divide‐and‐color: Kneis, Molle, Richter, Rossmanith [2006] • We shall look at three approaches to solve the Extended Longest Path problem. 1. Method of Random Orientaons [Alon et al.] 2. Color‐coding [Alon et al.] 3. Divide‐and‐color [Kneis et al.] Method of Random Orientaons • Movaon for the method • Consider adjacency matrix, A of G = (V,E). A has 0/1 entries (we’ll interpret them as integers). Now, A[i][j] ≠ 0 ⇒ there exists an edge between verces, i and j in the graph. • Movaon for the method Consider matrix, A2 = A × A. 2 → there exists a path of length 2 between A [i][ j] ≠ 0 verces, € i and j. Generalizing, we can say:‐ € there exists a path of length Ak[i][ j] ≠ 0 → k between verces i and j. € • Movaon for the method • Each entry in the matrix, corresponds to a path of Ak length k. • Queson: Do entries of correspond to Ak simple paths of length k€? • In other words, is the following statement true: € k there exists a A [i][ j] ≠ 0 → simple path of length k between verces, i and j. (?). € • Movaon for the method Answer: No. Remarks: 1. The paths represented by the matrix entries may Contain cycles. Hence the statement is not true. 2. If the statement were true, we would have already solved in polynomial me the NP‐complete problem we set out to solve (and hence it is not true). • Movaon for the method • Simple Idea: If the graph itself did not have cycles, then all paths in the graph would be simple. Hence, we could then use the matrix, of that graph, Ak to find all pairs of verces having simple paths of length k between them. € • Movaon for the method • Queson: How do we convert the given graph G=(V,E) into an acyclic graph? • Soluon: Convert G into a Directed Acyclic Graph. Method of Random Orientaons • Idea • Take a random permutaon, π : V → {1, …, |V|} of the Vertex Set, V of G. • Orient each edge {i,j} of E from i to j iff π(i) < π(j). Remark: By orienng edges in this manner, all cycles in the original graph get broken. Method of Random Orientaons • Method: • Call the directed acyclic graph obtained from G as Ga . • Let B be the adjacency matrix of Ga . Method of Random Orientaons • Method k • there exists a simple path of B [i][ j] ≠ 0 → length k between verces i and j in Ga. • This in turn implies that there exists a simple path of length k between verces i and j in the € original graph, G. Method of Random Orientaons • Method • Queson: Are all simple paths of G preserved in Ga ? (Suppose p is a simple path in G; do the edges forming p form a simple path in Ga ? ) • Answer: No. Method of Random Orientaons • Method • Example: Method of Random Orientaons • Method • Given a simple path, p in G of length k. What is the probability that p is preserved in Ga ? • Answer: 2/ (k+1)! • Therefore, we need to repeat the algorithm with an expected number of O( (k+1)!) permutaons to find all k‐length simple paths of G. Method of Random Orientaons • We can now state the algorithm. • Input: undirected graph, G=(V,E), integer k ≥ 0. • Repeat (k+1)! / 2 mes. 1. Take a random permutaon, π and convert G into a directed acyclic graph based on π. 2. Compute to find all pairs of verces having a Bk simple path of length k between them under permutaon π. € Method of Random Orientaons • Running Time • For a parcular permutaon, π – compung k takes B O(log k) matrix mulplicaons, each taking me. O(V ω ) • We repeat the same for (k+1)! permutaons. € • Running me: O( (k+1)! poly(V,E,k) ) € Color‐coding • Movaon for color‐coding:‐ • Random orientaons method has a (k+1)! term in the running me. Color‐coding • Idea • Color each vertex in the vertex set of input graph G with one color from a set of colors. • Instead of trying to find a simple path, try to find a “Colorful path” in the colored graph. Color‐coding • Idea • Colorful path: A path in which each vertex along the path has a disnct color. • Example: Color‐coding • Idea • A colorful path is necessarily simple. Therefore, if we find that there exists a colorful path of length k, between verces u and v in the colored graph, then there exists a simple path of length k between u and v in the original graph. Color‐coding • Our aim now is to find a colorful path of length k in a colored graph. • Input: Colored graph G=(V,E) [each vertex is Colored with one color from a set of (k+1) Colors], integer k ≥ 0. • To find: All pairs of verces in V having a Colorful path of length k between them. Color‐coding • Finding colorful paths in a colored graph • Simple dynamic programming algorithm (This algorithm finds all verces, v such that there is a Colorful path of length k between v and a disnguished start vertex, s.) • i.e. Input: colored graph G=(V,E), integer k ≥ 0, start vertex, s ∈V. Color‐coding • Dynamic Programming algorithm • Idea/Example • Suppose we have a colorful path of length, 3 from s to some vertex, v. • Now, suppose we wish to extend the path to vertex x (assuming edge {v3,x} exists). • We need to ensure that Color(x) is disnct from all 4 Colors present in the current path. Color‐coding • Idea behind dynamic programming algorithm (1) In order to extend a path of length i into a path of length i+1, we need to know the set of colors used up so far in the path of length i. Color‐coding • Idea behind dynamic programming algorithm • Example: • We want to extend ll vertex x, the colorful path of length 3 from s to v3. • Now, the colorful path s – v1 – v2 –v3 cannot be extended to x, while the colorful path s – v5 – v4 – v3 Can. Color‐coding • Idea behind dynamic programming algorithm • Example: • (We have 2 colorful paths from s to v3, which we want to extend to vertex x.) • Since we are only interested in the color‐set used in the current path, and not its actual verces, we do not to store different paths having idencal color‐sets. • Storing only disnct color‐sets will suffice. Color‐coding • Idea behind dynamic programming algorithm (2) For proceeding from a colorful path of length i to one of length i+1, for each vertex, v we will store all sets of colors that are present on colorful path(s) of length i between s and v. • There can be at most C(k+1,i+1) = (k+1)! / ( i+1)! * (k‐i)!) such colors sets for each vertex v. Color‐coding • Idea behind dynamic programming algorithm • At any iteraon, we take all colorful paths of length i ( 0≤ i ≤ k‐1), and try to extend them to obtain colorful paths of length i+1. • We start with colorful paths of length 0. (The vertex, “s” is the only such path.) • At the end of the iteraon (for proceeding from paths ith . of length (i‐1) to i, for each vertex v ∈V, we store:‐ All color‐sets in colorful paths of length i‐1 from s to v. (Note: Each color‐set would have exactly € i colors; and there can be at most C(k+1,i) such color‐sets. ) Color‐coding • Dynamic Programming algorithm • Proceeding from ith iteraon to (i+1)th iteraon:‐ • Consider a vertex, v ∈V. • Compare Color(v) with each of the color‐sets (each having i colors) of each of it’s neighbors. • All color‐sets (having i+1 colors that result in a colorful path of length i from s to v, now form the collecon of Color‐sets of v aer iteraon i+1.) • Repeat the above 2 steps for every vertex in V. Color‐coding • At the end of the algorithm: If there exists at least one color‐set for any vertex, v (corresponding to colorful paths of length k), then there exists a colorful path of length k between s and v. Converse is also true. Color‐coding • Dynamic Programming algorithm • Running me: • At each iteraon: O( C(k+1,i)*i*E) • Therefore, running me over all iteraons is: k k , which is . O(∑C(k +1,i)*i * E) O(k *2 * E) i=1 € The above is for finding colorful paths from a parcular € start vertex, under a given coloring. • We repeat the above procedure once for each vertex. • Therefore, running me is . O(k *2k *V * E) € Color‐coding • Queson: Are all simple paths of length k in the (uncolored) input graph G, preserved under a random coloring of the verces of G (using k+1 colors)? • i.e.
Recommended publications
  • Applications of DFS
    (b) acyclic (tree) iff a DFS yeilds no Back edges 2.A directed graph is acyclic iff a DFS yields no back edges, i.e., DAG (directed acyclic graph) , no back edges 3. Topological sort of a DAG { next 4. Connected components of a undirected graph (see Homework 6) 5. Strongly connected components of a drected graph (see Sec.22.5 of [CLRS,3rd ed.]) Applications of DFS 1. For a undirected graph, (a) a DFS produces only Tree and Back edges 1 / 7 2.A directed graph is acyclic iff a DFS yields no back edges, i.e., DAG (directed acyclic graph) , no back edges 3. Topological sort of a DAG { next 4. Connected components of a undirected graph (see Homework 6) 5. Strongly connected components of a drected graph (see Sec.22.5 of [CLRS,3rd ed.]) Applications of DFS 1. For a undirected graph, (a) a DFS produces only Tree and Back edges (b) acyclic (tree) iff a DFS yeilds no Back edges 1 / 7 3. Topological sort of a DAG { next 4. Connected components of a undirected graph (see Homework 6) 5. Strongly connected components of a drected graph (see Sec.22.5 of [CLRS,3rd ed.]) Applications of DFS 1. For a undirected graph, (a) a DFS produces only Tree and Back edges (b) acyclic (tree) iff a DFS yeilds no Back edges 2.A directed graph is acyclic iff a DFS yields no back edges, i.e., DAG (directed acyclic graph) , no back edges 1 / 7 4. Connected components of a undirected graph (see Homework 6) 5.
    [Show full text]
  • On Computing Longest Paths in Small Graph Classes
    On Computing Longest Paths in Small Graph Classes Ryuhei Uehara∗ Yushi Uno† July 28, 2005 Abstract The longest path problem is to find a longest path in a given graph. While the graph classes in which the Hamiltonian path problem can be solved efficiently are widely investigated, few graph classes are known to be solved efficiently for the longest path problem. For a tree, a simple linear time algorithm for the longest path problem is known. We first generalize the algorithm, and show that the longest path problem can be solved efficiently for weighted trees, block graphs, and cacti. We next show that the longest path problem can be solved efficiently on some graph classes that have natural interval representations. Keywords: efficient algorithms, graph classes, longest path problem. 1 Introduction The Hamiltonian path problem is one of the most well known NP-hard problem, and there are numerous applications of the problems [17]. For such an intractable problem, there are two major approaches; approximation algorithms [20, 2, 35] and algorithms with parameterized complexity analyses [15]. In both approaches, we have to change the decision problem to the optimization problem. Therefore the longest path problem is one of the basic problems from the viewpoint of combinatorial optimization. From the practical point of view, it is also very natural approach to try to find a longest path in a given graph, even if it does not have a Hamiltonian path. However, finding a longest path seems to be more difficult than determining whether the given graph has a Hamiltonian path or not.
    [Show full text]
  • Approximating the Maximum Clique Minor and Some Subgraph Homeomorphism Problems
    Approximating the maximum clique minor and some subgraph homeomorphism problems Noga Alon1, Andrzej Lingas2, and Martin Wahlen2 1 Sackler Faculty of Exact Sciences, Tel Aviv University, Tel Aviv. [email protected] 2 Department of Computer Science, Lund University, 22100 Lund. [email protected], [email protected], Fax +46 46 13 10 21 Abstract. We consider the “minor” and “homeomorphic” analogues of the maximum clique problem, i.e., the problems of determining the largest h such that the input graph (on n vertices) has a minor isomorphic to Kh or a subgraph homeomorphic to Kh, respectively, as well as the problem of finding the corresponding subgraphs. We term them as the maximum clique minor problem and the maximum homeomorphic clique problem, respectively. We observe that a known result of Kostochka and √ Thomason supplies an O( n) bound on the approximation factor for the maximum clique minor problem achievable in polynomial time. We also provide an independent proof of nearly the same approximation factor with explicit polynomial-time estimation, by exploiting the minor separator theorem of Plotkin et al. Next, we show that another known result of Bollob´asand Thomason √ and of Koml´osand Szemer´ediprovides an O( n) bound on the ap- proximation factor for the maximum homeomorphic clique achievable in γ polynomial time. On the other hand, we show an Ω(n1/2−O(1/(log n) )) O(1) lower bound (for some constant γ, unless N P ⊆ ZPTIME(2(log n) )) on the best approximation factor achievable efficiently for the maximum homeomorphic clique problem, nearly matching our upper bound.
    [Show full text]
  • Downloaded the Biochemical Pathways Information from the Saccharomyces Genome Database (SGD) [29], Which Contains for Each Enzyme of S
    Algorithms 2015, 8, 810-831; doi:10.3390/a8040810 OPEN ACCESS algorithms ISSN 1999-4893 www.mdpi.com/journal/algorithms Article Finding Supported Paths in Heterogeneous Networks y Guillaume Fertin 1;*, Christian Komusiewicz 2, Hafedh Mohamed-Babou 1 and Irena Rusu 1 1 LINA, UMR CNRS 6241, Université de Nantes, Nantes 44322, France; E-Mails: [email protected] (H.M.-B.); [email protected] (I.R.) 2 Institut für Softwaretechnik und Theoretische Informatik, Technische Universität Berlin, Berlin D-10587, Germany; E-Mail: [email protected] y This paper is an extended version of our paper published in the Proceedings of the 11th International Symposium on Experimental Algorithms (SEA 2012), Bordeaux, France, 7–9 June 2012, originally entitled “Algorithms for Subnetwork Mining in Heterogeneous Networks”. * Author to whom correspondence should be addressed; E-Mail: [email protected]; Tel.: +33-2-5112-5824. Academic Editor: Giuseppe Lancia Received: 17 June 2015 / Accepted: 29 September 2015 / Published: 9 October 2015 Abstract: Subnetwork mining is an essential issue in the analysis of biological, social and communication networks. Recent applications require the simultaneous mining of several networks on the same or a similar vertex set. That is, one searches for subnetworks fulfilling different properties in each input network. We study the case that the input consists of a directed graph D and an undirected graph G on the same vertex set, and the sought pattern is a path P in D whose vertex set induces a connected subgraph of G. In this context, three concrete problems arise, depending on whether the existence of P is questioned or whether the length of P is to be optimized: in that case, one can search for a longest path or (maybe less intuitively) a shortest one.
    [Show full text]
  • On Digraph Width Measures in Parameterized Algorithmics (Extended Abstract)
    On Digraph Width Measures in Parameterized Algorithmics (extended abstract) Robert Ganian1, Petr Hlinˇen´y1, Joachim Kneis2, Alexander Langer2, Jan Obdrˇz´alek1, and Peter Rossmanith2 1 Faculty of Informatics, Masaryk University, Brno, Czech Republic {xganian1,hlineny,obdrzalek}@fi.muni.cz 2 Theoretical Computer Science, RWTH Aachen University, Germany {kneis,langer,rossmani}@cs.rwth-aachen.de Abstract. In contrast to undirected width measures (such as tree- width or clique-width), which have provided many important algo- rithmic applications, analogous measures for digraphs such as DAG- width or Kelly-width do not seem so successful. Several recent papers, e.g. those of Kreutzer–Ordyniak, Dankelmann–Gutin–Kim, or Lampis– Kaouri–Mitsou, have given some evidence for this. We support this di- rection by showing that many quite different problems remain hard even on graph classes that are restricted very beyond simply having small DAG-width. To this end, we introduce new measures K-width and DAG- depth. On the positive side, we also note that taking Kant´e’s directed generalization of rank-width as a parameter makes many problems fixed parameter tractable. 1 Introduction The very successful concept of graph tree-width was introduced in the context of the Graph Minors project by Robertson and Seymour [RS86,RS91], and it turned out to be very useful for efficiently solving graph problems. Tree-width is a property of undirected graphs. In this paper we will be interested in directed graphs or digraphs. Naturally, a width measure specifically tailored to digraphs with all the nice properties of tree-width would be tremendously useful. The properties of such a measure should include at least the following: i) The width measure is small on many interesting instances.
    [Show full text]
  • Fixed-Parameter Algorithms for Longest Heapable Subsequence and Maximum Binary Tree
    Fixed-Parameter Algorithms for Longest Heapable Subsequence and Maximum Binary Tree Karthekeyan Chandrasekaran∗ Elena Grigorescuy Gabriel Istratez Shubhang Kulkarniy Young-San Liny Minshen Zhuy November 23, 2020 Abstract A heapable sequence is a sequence of numbers that can be arranged in a min-heap data structure. Finding a longest heapable subsequence of a given sequence was proposed by Byers, Heeringa, Mitzenmacher, and Zervas (ANALCO 2011) as a generalization of the well-studied longest increasing subsequence problem and its complexity still remains open. An equivalent formulation of the longest heapable subsequence problem is that of finding a maximum-sized binary tree in a given permutation directed acyclic graph (permutation DAG). In this work, we study parameterized algorithms for both longest heapable subsequence as well as maximum-sized binary tree. We show the following results: 1. The longest heapable subsequence problem can be solved in kO(log k)n time, where k is the number of distinct values in the input sequence. 2. We introduce the alphabet size as a new parameter in the study of computational prob- lems in permutation DAGs. Our result on longest heapable subsequence implies that the maximum-sized binary tree problem in a given permutation DAG is fixed-parameter tractable when parameterized by the alphabet size. 3. We show that the alphabet size with respect to a fixed topological ordering can be com- puted in polynomial time, admits a min-max relation, and has a polyhedral description. 4. We design a fixed-parameter algorithm with run-time wO(w)n for the maximum-sized bi- nary tree problem in undirected graphs when parameterized by treewidth w.
    [Show full text]
  • 9 the Graph Data Model
    CHAPTER 9 ✦ ✦ ✦ ✦ The Graph Data Model A graph is, in a sense, nothing more than a binary relation. However, it has a powerful visualization as a set of points (called nodes) connected by lines (called edges) or by arrows (called arcs). In this regard, the graph is a generalization of the tree data model that we studied in Chapter 5. Like trees, graphs come in several forms: directed/undirected, and labeled/unlabeled. Also like trees, graphs are useful in a wide spectrum of problems such as com- puting distances, finding circularities in relationships, and determining connectiv- ities. We have already seen graphs used to represent the structure of programs in Chapter 2. Graphs were used in Chapter 7 to represent binary relations and to illustrate certain properties of relations, like commutativity. We shall see graphs used to represent automata in Chapter 10 and to represent electronic circuits in Chapter 13. Several other important applications of graphs are discussed in this chapter. ✦ ✦ ✦ ✦ 9.1 What This Chapter Is About The main topics of this chapter are ✦ The definitions concerning directed and undirected graphs (Sections 9.2 and 9.10). ✦ The two principal data structures for representing graphs: adjacency lists and adjacency matrices (Section 9.3). ✦ An algorithm and data structure for finding the connected components of an undirected graph (Section 9.4). ✦ A technique for finding minimal spanning trees (Section 9.5). ✦ A useful technique for exploring graphs, called “depth-first search” (Section 9.6). 451 452 THE GRAPH DATA MODEL ✦ Applications of depth-first search to test whether a directed graph has a cycle, to find a topological order for acyclic graphs, and to determine whether there is a path from one node to another (Section 9.7).
    [Show full text]
  • A Low Complexity Topological Sorting Algorithm for Directed Acyclic Graph
    International Journal of Machine Learning and Computing, Vol. 4, No. 2, April 2014 A Low Complexity Topological Sorting Algorithm for Directed Acyclic Graph Renkun Liu then return error (graph has at Abstract—In a Directed Acyclic Graph (DAG), vertex A and least one cycle) vertex B are connected by a directed edge AB which shows that else return L (a topologically A comes before B in the ordering. In this way, we can find a sorted order) sorting algorithm totally different from Kahn or DFS algorithms, the directed edge already tells us the order of the Because we need to check every vertex and every edge for nodes, so that it can simply be sorted by re-ordering the nodes the “start nodes”, then sorting will check everything over according to the edges from a Direction Matrix. No vertex is again, so the complexity is O(E+V). specifically chosen, which makes the complexity to be O*E. An alternative algorithm for topological sorting is based on Then we can get an algorithm that has much lower complexity than Kahn and DFS. At last, the implement of the algorithm by Depth-First Search (DFS) [2]. For this algorithm, edges point matlab script will be shown in the appendix part. in the opposite direction as the previous algorithm. The algorithm loops through each node of the graph, in an Index Terms—DAG, algorithm, complexity, matlab. arbitrary order, initiating a depth-first search that terminates when it hits any node that has already been visited since the beginning of the topological sort: I.
    [Show full text]
  • CS302 Final Exam, December 5, 2016 - James S
    CS302 Final Exam, December 5, 2016 - James S. Plank Question 1 For each of the following algorithms/activities, tell me its running time with big-O notation. Use the answer sheet, and simply circle the correct running time. If n is unspecified, assume the following: If a vector or string is involved, assume that n is the number of elements. If a graph is involved, assume that n is the number of nodes. If the number of edges is not specified, then assume that the graph has O(n2) edges. A: Sorting a vector of uniformly distributed random numbers with bucket sort. B: In a graph with exactly one cycle, determining if a given node is on the cycle, or not on the cycle. C: Determining the connected components of an undirected graph. D: Sorting a vector of uniformly distributed random numbers with insertion sort. E: Finding a minimum spanning tree of a graph using Prim's algorithm. F: Sorting a vector of uniformly distributed random numbers with quicksort (average case). G: Calculating Fib(n) using dynamic programming. H: Performing a topological sort on a directed acyclic graph. I: Finding a minimum spanning tree of a graph using Kruskal's algorithm. J: Finding the minimum cut of a graph, after you have found the network flow. K: Finding the first augmenting path in the Edmonds Karp implementation of network flow. L: Processing the residual graph in the Ford Fulkerson algorithm, once you have found an augmenting path. Question 2 Please answer the following statements as true or false. A: Kruskal's algorithm requires a starting node.
    [Show full text]
  • Merkle Trees and Directed Acyclic Graphs (DAG) As We've Discussed, the Decentralized Web Depends on Linked Data Structures
    Merkle trees and Directed Acyclic Graphs (DAG) As we've discussed, the decentralized web depends on linked data structures. Let's explore what those look like. Merkle trees A Merkle tree (or simple "hash tree") is a data structure in which every node is hashed. +--------+ | | +---------+ root +---------+ | | | | | +----+---+ | | | | +----v-----+ +-----v----+ +-----v----+ | | | | | | | node A | | node B | | node C | | | | | | | +----------+ +-----+----+ +-----+----+ | | +-----v----+ +-----v----+ | | | | | node D | | node E +-------+ | | | | | +----------+ +-----+----+ | | | +-----v----+ +----v-----+ | | | | | node F | | node G | | | | | +----------+ +----------+ In a Merkle tree, nodes point to other nodes by their content addresses (hashes). (Remember, when we run data through a cryptographic hash, we get back a "hash" or "content address" that we can think of as a link, so a Merkle tree is a collection of linked nodes.) As previously discussed, all content addresses are unique to the data they represent. In the graph above, node E contains a reference to the hash for node F and node G. This means that the content address (hash) of node E is unique to a node containing those addresses. Getting lost? Let's imagine this as a set of directories, or file folders. If we run directory E through our hashing algorithm while it contains subdirectories F and G, the content-derived hash we get back will include references to those two directories. If we remove directory G, it's like Grace removing that whisker from her kitten photo. Directory E doesn't have the same contents anymore, so it gets a new hash. As the tree above is built, the final content address (hash) of the root node is unique to a tree that contains every node all the way down this tree.
    [Show full text]
  • Optimal Longest Paths by Dynamic Programming∗
    Optimal Longest Paths by Dynamic Programming∗ Tomáš Balyo1, Kai Fieger1, and Christian Schulz1,2 1 Karlsruhe Institute of Technology, Karlsruhe, Germany {tomas.balyo, christian.schulz}@kit.edu, fi[email protected] 2 University of Vienna, Vienna, Austria [email protected] Abstract We propose an optimal algorithm for solving the longest path problem in undirected weighted graphs. By using graph partitioning and dynamic programming, we obtain an algorithm that is significantly faster than other state-of-the-art methods. This enables us to solve instances that have previously been unsolved. 1998 ACM Subject Classification G.2.2 Graph Theory Keywords and phrases Longest Path, Graph Partitioning Digital Object Identifier 10.4230/LIPIcs.SEA.2017. 1 Introduction The longest path problem (LP) is to find a simple path of maximum length between two given vertices of a graph where length is defined as the number of edges or the total weight of the edges in the path. The problem is known to be NP-complete [5] and has several applications such as designing circuit boards [8, 7], project planning [2], information retrieval [15] or patrolling algorithms for multiple robots in graphs [9]. For example, when designing circuit boards where the length difference between wires has to be kept small [8, 7], the longest path problem manifests itself when the length of shorter wires is supposed to be increased. Another example application is project planning/scheduling where the problem can be used to determine the least amount of time that a project could be completed in [2]. We organize the rest of paper as follows.
    [Show full text]
  • Graph Algorithms G
    Bipartiteness Graph G = (V,E) is bipartite iff it can be partitioned into two sets of nodes A and B such that each edge has one end in A and the other Introduction to Algorithms end in B Alternatively: Graph Algorithms • Graph G = (V,E) is bipartite iff all its cycles have even length • Graph G = (V,E) is bipartite iff nodes can be coloured using two colours CSE 680 Question: given a graph G, how to test if the graph is bipartite? Prof. Roger Crawfis Note: graphs without cycles (trees) are bipartite bipartite: non bipartite Testing bipartiteness Toppgological Sort Method: use BFS search tree Recall: BFS is a rooted spanning tree. Algorithm: Want to “sort” or linearize a directed acyygp()clic graph (DAG). • Run BFS search and colour all nodes in odd layers red, others blue • Go through all edges in adjacency list and check if each of them has two different colours at its ends - if so then G is bipartite, otherwise it is not A B D We use the following alternative definitions in the analysis: • Graph G = (V,E) is bipartite iff all its cycles have even length, or • Graph G = (V, E) is bipartite iff it has no odd cycle C E A B C D E bipartit e non bipartite Toppgological Sort Example z PerformedonaPerformed on a DAG. A B D z Linear ordering of the vertices of G such that if 1/ (u, v) ∈ E, then u appears before v. Topological-Sort (G) 1. call DFS(G) to compute finishing times f [v] for all v ∈ V 2.
    [Show full text]