A Fast Algorithm For Finding Hamilton Cycles


 Mervin York
 2 years ago
 Views:
Transcription
1 A Fast Algorithm For Finding Hamilton Cycles by Andrew Chalaturnyk A thesis presented to the University of Manitoba in partial fulfillment of the requirements for the degree of Masters of Science in Computer Science Winnipeg, Manitoba, Canada Summer 2008 c Andrew Chalaturnyk 2008
2 Abstract This thesis is concerned with an algorithmic study of the Hamilton cycle problem. Determining if a graph is Hamiltonian is well known to be an NP Complete problem, so a single most efficient algorithm is not known. Improvements to the understanding of any single NP Complete problem may also be of interest to other NP Complete problems. However, it is an important problem and creating an algorithm which is efficient for many families of graphs is desirable. The majority of the work described within starts with an exhaustive backtracking search, called the MultiPath method and explores two main areas: Creating an algorithm based upon the method which is both efficient in time and memory when implemented in code. Developing a pruning condition based upon separating sets that may be found during the execution of the method in order to maximize the amount of pruning possible. Both of these areas represent a significant evolution of previous work done with the method. The resulting algorithm is extremely fast and requires only O(n + ε) space in memory, where n is the number of vertices and ε is the number of edges. Additionally a class of graphs based on the Meredith graph is described. These graphs have a property which significantly affects the performance of the multipath method. The insights that follow from this property lead to a reduction technique that further improves the algorithm in a significant way when determining if graphs ii
3 Abstract iii are nonhamiltonian. Further directions for study along the lines pursued by these insights is discussed. Testing of the algorithm is performed on a family of graphs known as knight s move graphs, which are known to be difficult for algorithms dealing with Hamilton cycles.
4 Contents Title Page Abstract Table of Contents i ii iv 1 Introduction 1 2 Graph Theory Concepts Basic Terminology Graphical Representation Paths and Cycles Connectivity Bipartitions Isomorphism The MultiPath Method An Exhaustive Search Incident Edges about v Limiting Edges MultiPath Method Simplifying the Search Reducing G Removal of Branching Edges The Search Space Example: Petersen Graph Considerations for Algorithm Design Data Structures Adjacency Matrix and Lists Degree Values and Virtual Edges Segment and Cycle Storage Reducing Time and Space Overhead iv
5 Contents v 5.3 Detecting Stopping Conditions Tracking Forced Vertices Designing the MultiPath Algorithm Efficient Reduction and Recovery Extending Segments Managing Removed Edges Unwinding Segments and Restoring State Vertex Selection Navigating the Search Space using a Turing Machine State of the Tape Edges from E(S) Status Flags represented by the BitField Moving Read/Write Head Moving Right Moving Left Switching Directions Implementation of the MultiPath Algorithm Data Graph State Removed Edges Tape State Code Running the Turing Machine Extending Segments and Branching Restoring State and Removing Branching Edges Pruning Algorithm Pruning Mechanism Testing for Separating Sets Overview of Previous Test Increasing ω(g r K) K Reducing the Frequency of Testing Top Down vs. Bottom Up Testing Testing at the Extremities of the Search Space Ensuring a Full Climb up the Search Tree Implementation Data Structures Code
6 Contents vi 10 Reduction Technique Hamiltonian Subgraphs HalfBipartite Structures Finding Reducible Complete HalfBipartite Structures Reducing G False positives: an Unwanted Side Effect of Reduction Analysis and Verification Verification Analysis Knight s Move Graphs Complete Graphs Reduction Technique on the Meredith Graph Further Work MultiPath Algorithm A Closer Examination of Vertex Order Algorithm for Directed Graphs Fine Tuning for the TSP A WorkStealing Parallel Implementation Pruning Algorithm Constructing Components for Better Separating Sets Reduction Technique Finding More Reducible Subgraphs Reconstructing Hamilton Cycles in G α A MultiPath Code 99 A.1 Data Types A.2 Extending Segments A.2.1 Support Routines for Extending Segments A.2.2 Main Routine for Extending Segments A.3 Extending Branches A.4 Restoring Graph B Pruning Algorithm 115 B.1 Data Types B.2 Depth First Search (DFS) B.2.1 Main DFS algorithm B.2.2 Routine for calculating Component / Separating Set differences. 119 B.3 Turing Machine for Pruning Condition B.3.1 Pruning B.3.2 Main Turing Machine Code
7 Chapter 1 Introduction This thesis describes work that improves and extends upon an algorithm for finding Hamilton cycles in graphs. Named for Sir William Rowan Hamilton, the popularity of the problem of finding Hamilton cycles originates from the Icosian Game invented by Hamilton. The object of the game is to find a continuous route along the edges of a dodecahedron that visit all of its corners exactly once and ends at the starting corner. A graph can be visualized as a collection of points, or vertices, connected by lines, or edges. A cycle is a walk along a path of edges visiting vertices until ending at the originating vertex. A Hamilton cycle is a cycle that visits every vertex in a graph exactly once. The difficulty of finding Hamilton cycles increases with the number of vertices in a graph. Not all graphs contain a Hamilton cycle, and those that do are referred to as Hamiltonian graphs. Determining if a graph is Hamiltonian can take an extremely long time. In the broad field of Computer Science the problem of determining if a graph is 1
8 Chapter 1: Introduction 2 Hamiltonian is known to be in the class of NPcomplete problems. Simply put, the time it takes to solve NPcomplete problems can rise exponentially with the problem size. Another NPcomplete problem very closely related is the Traveling Salesman Problem. The nature of the Hamilton Cycle problem is such that no single most efficient algorithm is known [Van98]. In [Van98], Vandegriend provides a survey of different Hamiltonian algorithms and the problems encountered that can cause extreme slowdowns during algorithm execution. Any improvements that can be made to speed up solutions to both determining if a graph is Hamiltonian and finding Hamiltonian cycles are of interest. Also, because
9 Chapter 1: Introduction 3 of the complexity of the problem, improvements may reveal more insight into the qualities of graphs that make them Hamiltonian. Due to the nature of NPcomplete problems, all problems in the class NP may benefit from improvements or insights found. The multipath method introduced by Rubin [Rub74] and Christofides [Chr75] is an exhaustive search for all possible Hamilton cycles that can be found within a graph. The work by Kocay [Koc92], implements the method with an algorithm that overlays additional pruning capabilities into the search. Under certain conditions the improvements in [Koc92] can allow for significant pruning of the search tree generated by the multipath algorithm. This thesis extends and improves on the work in [Koc92] with two major improvements and introduces a method for dealing with certain special graphs that can lead to exponential increases in the performance of the algorithm. As with the work from [Koc92], the work described here is for finding Hamilton cycles in undirected simple graphs. The first of the improvements is to the design and implementation of the algorithm in [Koc92]. These improvements result in reduced runtime and decreased memory use and are significant code optimizations. The memory reduction is by an order of magnitude in terms of the number of vertices in the graph. The runtime improvement is linear with respect to the complexity and size of the graph. The second of the improvements is to the scope and frequency of the pruning enhancement from [Koc92]. The new method focuses on a recursive graph reduction technique that can be ap
10 Chapter 1: Introduction 4 plied repeatedly to graphs that contain subgraphs with a certain interesting property. The contents of this thesis is organized in the following way: Chapter 2 introduces and describes common graph theory concepts that are used throughout this work. Chapters 3 and 4 introduce and describe the multipath method in detail. Chapter 5 discusses algorithm details with respect to the required data structures needed for the new multipath algorithm and compares against those needed by the previous algorithm from [Koc92]. Chapters 6, 7 and 8 describe the new multipath algorithm and its improvements over its predecessor from [Koc92]. Chapter 9 introduces the pruning technique and describes the improvements to it from [Koc92]. Chapter 10 introduces the reduction technique and shows how it can be used to speed up detection of certain nonhamiltonian graphs. Chapter 11 discusses how the work for this thesis was verified and provides some analysis of the improvements introduced. Chapter 12 discusses some further directions research into this problem could take, based upon the work provided by this thesis.
11 Chapter 2 Graph Theory Concepts 2.1 Basic Terminology A graph G is composed of a set V (G) of vertices and a set E(G) of edges. It is assumed that n = V (G) and ε = E(G). Every edge e E(G) is composed of a set e = {u, v} where u, v V (G). In undirected graphs, edges are unordered pairs of vertices. In directed graphs, edges or arcs are ordered pairs of vertices. Simple graphs do not allow edges to repeat and the vertices in an edge must be distinct. Only simple graphs are considered here. The edges from E(G) which contain v are said to be incident to v. The two vertices incident to an edge are said to be adjacent. Given the graph G and two vertices u and v from V (G), u v means that u and v are adjacent. u v indicates that u and v are not adjacent. 5
12 Chapter 2: Graph Theory Concepts 6 Figure 2.1: Three drawings of the Petersen graph. 2.2 Graphical Representation As an abstraction, a graph G is represented mathematically as composed of two sets V (G) and E(G). Visually this can be represented as a collection of points, V (G), connected by lines, E(G). The coordinates of the points or the shape of the lines do not matter. The same graph G can therefore be represented visually by an infinite number of drawings. Depending on the drawing, different attributes of a graph may become more apparent to the observer. For instance the drawing on the right hand side of figure 2.1 suggests that there may be a Hamilton cycle in the Petersen graph. While the Petersen graph is not Hamiltonian, using the same graphical orientation of fitting adjacent vertices around a circle is a useful representation to help in finding Hamilton cycles in relatively small graphs using simple observation. 2.3 Paths and Cycles A path in G is defined to be an ordered sequence of distinct vertices such that every vertex in the sequence is adjacent to the vertex that immediately precedes it and adjacent to the vertex that immediately follows it. This can be written as
13 Chapter 2: Graph Theory Concepts 7 u 1 u 2 u k, where u 1 through u k are all distinct vertices from V (G). A cycle in the G is defined as a path in G that terminates on the starting vertex. The number of edges in a cycle is equal to the number of vertices. 2.4 Connectivity Figure 2.2: Example of a graph with a separating set. If a path exists between two distinct vertices, v, u V (G), they are called connected. A graph G is connected if every pair of distinct vertices from V (G) is connected. A component in G is a maximal subgraph of G that is connected. A graph with more than one component is called disconnected. In a connected graph G, a separating set is a set of vertices from G that when
14 Chapter 2: Graph Theory Concepts 8 removed, disconnects G. A separating set, K, with m = K, is called minimum when there is no other separating set in G smaller than m. A cutpoint in G is a single vertex from G that forms a separating set in G. 2.5 Bipartitions A bipartition exists in a graph G, if V (G) can be divided into two distinct sets, A and B, where A B = and A B = V (G), and no two vertices from the same set are adjacent. A graph with a bipartition is referred to as bipartite. 2.6 Isomorphism An isomorphism is a onetoone mapping between vertices of two graphs that preserves the connections, or edges, between vertices. If an isomorphism exists, the two graphs are said to be isomorphic. The three drawings of the Petersen graph in figure 2.1 are isomorphic to each other.
15 Chapter 3 The MultiPath Method This chapter describes the multipath method for finding Hamilton cycles. While it was originally proposed by Rubin in [Rub74], the description of the multipath method within this chapter is a synthesis of the descriptions from [Koc92, Chr75] as well as the work described by this thesis. To facilitate understanding of both the multipath method and the enhancements to it some preliminary ground must be covered. Section 3.1 describes a truly exhaustive method of finding Hamilton cycles. Sections 3.2 and 3.3 describe two improvements that can be used to reduce the amount of search required and section 3.4 combines the results of the improvements to describe the multipath method. Finally in section 3.5, a few refinements that appear in [Koc92] are described and added to the method. Assume that all graphs G to be considered are nontrivial with respect to the Hamilton Cycle problem, implying that all vertices in any graph will be at least of degree three. 9
16 Chapter 3: The MultiPath Method 10 The algorithms described in this chapter are partial algorithms used as a tool to convey general information about the multipath method. Procedures that are not fully defined can be implicitly understood given their names and context of use. Each undefined procedure is assumed to be implementable by some algorithm with a polynomial overhead in time and space. 3.1 An Exhaustive Search By definition all vertices from V (G) must be part of any Hamilton cycle of G. The edges that make up any Hamilton cycle are what must be varied. One method to determine if a graph is Hamiltonian is to generate all combinations of n edges from E(G) until a Hamilton cycle is found or until no combinations are left. In the worst case, the number of edge combinations to try is ( ε n). The order in which edges are chosen with this method is not restricted by the order in which they would be traversed in a Hamilton cycle. When testing if the chosen edges form a Hamilton cycle the correct traversal order will implicitly be found. Let S be the subgraph of G describing a partial Hamilton cycle formed by choosing m edges, m < n, to be on the Hamilton cycle. S forms a subgraph in G, with E(S) and V (S) its edges and vertices. Obviously m = E(S). When m = n we have a candidate subgraph that will form a cycle iff G is Hamiltonian. Algorithm briefly describes a recursive procedure for generating and testing all possible combinations of edges up to the first Hamilton cycle found. The algorithm works by recursively fixing an edge within S and attempting all
17 Chapter 3: The MultiPath Method 11 possible edge combinations for the remaining n m positions to be filled with the current edges available. IsCycle verifies if E(S) describes a Hamilton cycle and ChooseEdge returns some unspecified edge from the remaining edges at the current depth in the search space. The recursive nature of the procedure allows for the search space of the algorithm to be modeled as a tree. In this case the depth is bounded by n and the number of leaves is bounded by ( ε n). Each node in the search tree represents this fixed position in S and the branches represent the current edge in that position. Algorithm 3.1.1: HCEdges( n, E, S ) All parameters passed by value. comment: Initially n = V (G), E = E(G) and S is empty. result = true G is Hamiltonian if E(S) = n then return (IsCycle(S)) while E = e ChooseEdge(E) do E E e if HCEdges( n, E, S + e ) then return ( true ) return ( false ) This type of algorithm is referred to as a backtracking algorithm. The ability to return to a specific spot while searching and ensuring that all possible permutations of decisions are attempted from that point characterize these kind of algorithms.
18 Chapter 3: The MultiPath Method Incident Edges about v Algorithm blindly generates edge combinations. If instead the focus is now placed on vertices, a significant fact emerges. All possible edge combinations about v V (G) use one of the deg(v) edges incident to v. There are up to ( ) deg(v) 2 ways of selecting pairs of incident edges in any possible cycle about v. Algorithm is a modification of algorithm to instead use vertices chosen by ChooseVertex, in the selection of edges. These vertices are referred to as anchor points. Instead of branching out with all remaining edges at the current spot in the search space, only edges incident to the anchor vertex v are chosen for branches. Similar to ChooseEdge from the previous algorithm, ChooseVertexEdge returns some unspecified edge incident to v from the remaining edges at the current depth in the search space. Algorithm 3.2.1: HCVertexEdges( n, V, E, S ) All parameters passed by value. comment: Initially n = V (G), V = V (G), E = E(G) and S is empty. result = true G is Hamiltonian if E(S) = n then return ( IsCycle(S) ) v ChooseVertex(V) if v V (S) then V V v while deg(e, v) 0 e b ChooseVertexEdge( v, E ) do E E e b if HCVertexEdges( n, V, E, S + e b ) then return ( true ) return ( false )
19 Chapter 3: The MultiPath Method 13 As seen in the algorithm a given vertex may be chosen twice when descending towards a leaf in the search space. This allows for the ( ) deg(v) 2 possible edge pairs about v to be explored iteratively and dramatically reduces the breadth of the search tree by limiting the total number of leaves while not removing any possible Hamilton cycle that could be found. The order and manner in which ChooseVertex picks vertices in V will be discussed later in section Limiting Edges Edge choices from E(G) can be limited based on the edges already chosen. For any v in a cycle, only two edges incident to v may be used and deg(v) = 2 with respect to the subgraph the cycle defines in G. Definition (segment). A segment is a path in G. Segments do not overlap or share endpoints with other segments. Let S i be a subgraph in G defined by some segment and let S = S 1... S k be the k segments formed from E(S). V ex (S) denotes the external vertices, or segment endpoints, and V in (S) denotes the internal degree 2 vertices with respect to S. As in the previous section, m = E(S). When adding another edge to S the choice of e m+1 E(G) is now limited to the edges of E(G V in (S)), as no more edges incident to the internal vertices in S can be chosen and still satisfy the degree 2 restriction. Inductively it can be seen when m starts at 0 and approaches n, only two edges
20 Chapter 3: The MultiPath Method 14 incident to a given v V (G) can ever be in E(S). The main idea of the multipath method is to construct a Hamilton cycle by piecing together the disjoint segments formed by the edges in S. 3.4 MultiPath Method The multipath method uses the two ideas from sections 3.2 and 3.3 to dramatically reduce the search space of algorithms and The selection of a new edge will eventually cause a chain reaction as each new v V in (S) may induce conditions that require unchosen additions to E(S). Let the vertex and edge sets for the derived graph M be: V (M) = V (G) V in (S) (3.1) E(M) = E E(G V in (S)) (3.2) Where E is the set of edges remaining in G to be selected for E(S). More on E will be described later in this section. For now, assume that E has been inherited from the parent node in the search space. E(M) represents the remaining edges available that may be added to E(S) at the point in the search space it is defined. Deriving M may result in one or more vertices in V (M) that no longer have any choice in what edges are placed into E(S), leading to the following definitions: Definition (forced vertex). A forced vertex is a vertex v V (M) where deg(v) = 2 when v V (S) or deg(v) = 1 when v V ex (S).
21 Chapter 3: The MultiPath Method 15 Definition (forced edge). An forced edge is an edge e E(M) where v e and v is a forced vertex. Forced vertices must be added to V in (S). These additions are accomplished by adding forced edges one at a time to E(S). The chain reaction occurs when the two vertices incident to a forced edge both belong to V ex (S). In this situation either a cycle is found or two segments are forced to merge. The two vertices incident to the forced edge that caused two segments to merge are called junction vertices and now belong to V in (S). Any edges not in E(S) that are incident to the junction vertices must be removed from M and may result in one or more additional forced vertices. Definition (consistent). M is said to be consistent if for all v M, deg(v) > 1 when v V ex (S) and deg(v) > 2 when v V ex (S). The chain reaction continues until M stabilizes and is found to be consistent or until a stop condition occurs. A stop condition can occur in three situations: Stop Condition (1A). v V ex (S) and deg(m, v) = 0 Stop Condition (1B). v V ex (S) and deg(m, v) = 1 Stop Condition (2). For some segment S i S there exists a forced edge, e E(M), such that the addition of e to S i would form a cycle. In this case if m = n a Hamilton cycle has been found. If m < n no Hamilton cycle can exist in the current S.
22 Chapter 3: The MultiPath Method 16 After each change to S a stop condition may occur in M. Algorithm describes this process of forcing edges into S and testing for a stop condition. Algorithm 3.4.1: ForceEdges( G, V, E, S ) All parameters passed by value. comment: Returns the set { V, E, S, stop } where stop is a boolean flag indicating a stop condition. E M E(G V in (S)) E V M V (G) V in (S) while not IsConsistent(V ex (S), E M ) S S + GetForcedEdge(V ex (S), E M ) E do M E(G V in (S)) E V M V (G) V in (S) if IsStopCondition(S, E M ) then return ( {,,, true } ) V V V M E E M return ( { V, E, S, false } ) Now that the process of forcing edges into S has been described, the rest of the method follows the same design as algorithm Using the first improvement from section 3.2, an anchor point v is chosen from V (M) and a single edge, e b, incident to v is selected from E(M) and added to E(S). This edge is referred to as a branching edge, and is a reflection of one of the two locations in the search space where choice is allowed in the algorithm. The other being the selection of anchor points. The overall shape and size of the search space is controlled by these choices. After removing e b, M may no longer be consistent and have edges to be forced into
23 Chapter 3: The MultiPath Method 17 S, ultimately reducing the number of anchor points and branching edges to choose from. Algorithm describes the multipath method using the ideas given so far. As previously mentioned and used in the previous algorithms, E represents the edges remaining in G that can be chosen for S. Edges are removed from E in two ways. The first is by the G V in (S) reduction. The second is by removal of branching edges, e b, that have had all possible combinations of E(S) attempted for the current location in the search space. Once a branching edge has been used, no more cycles can be found that contain that edge when continuing to search at the current depth in the search tree. Algorithm 3.4.2: HCMultiPath( G, V, E, S ) All parameters passed by value. comment: Initially V = V (G), E = E(G) and S is empty. result = true G is Hamiltonian { V, E, S, stop } ForceEdges( G, V, E, S ) if stop then return ( IsEqual( V (G), E(S) ) ) v ChooseVertex(V) while deg(e, v) 0 e b ChooseVertexEdge( v, E ) do E E e b if HCMultiPath( G, V, E, S + e b ) then return ( true ) return ( false ) As can be seen from the use of the stop conditions, no IsCycle test is required with the multipath method. This follows from the inductive reasoning provided at the end of section 3.3. If the algorithm ever allows E(S) to contain n edges, a
24 Chapter 3: The MultiPath Method 18 Hamilton cycle will be found. Taken together, both of the improvements reduce the total breadth and average depth of the search space. This is one of the major benefits of the multipath method. 3.5 Simplifying the Search A couple of minor improvements to the multipath method are now described that focus on simplifying movement through the search space. Both of these improvements are used by [Koc92]. Section introduces a reduction that can be applied to G in order to direct the path through the search space more efficiently. Section removes redundant recursive calls to the multipath method at a given node in the search space. Algorithms and reflect these improvements, and are the basis for the multipath algorithm developed and presented later on in this work Reducing G At any given node in the search space there is the original graph G, the set S of segments derived from the m edges selected so far and the derived graph M as described by equations 3.1 and 3.2. A reduced graph G SE defined by M and S may be defined for any point in the search space.
25 Chapter 3: The MultiPath Method 19 V (G SE ) = V (M) (3.3) E(G SE ) = E(M) + E v (S) (3.4) E v (S) is a set of virtual edges created to connect the segment endpoints in M. Each virtual edge represents a single segment from S at the current point in the search space. Let the edge {u,v} E v (S) be a virtual edge representing the segment S i S, then u, v V ex (S i ). Virtual edges may be thought of as the connections between unsearched sections of the graph. They may not be forced and can not be chosen for any E(S) as they already represent the edges that make up the segments already contained by S. Edges from M may be referred to as real edges. Real edges are what remains of the choices available to E(S) for any descendent point below the current in the search space. Due to equation 3.4 some of the conditions that define forced vertices, consistency and stop conditions can be simplified: Definition (forced vertex). A vertex v V (G SE ) where deg(v) = 2. Definition (consistent). G SE is said to be consistent if for all v V (G SE ), deg(v) > 2. Stop Condition (1). v V (G SE ) such that deg(v) = 1. In algorithms and 3.5.2, the variable G represents the reduced graph G SE.
26 Chapter 3: The MultiPath Method 20 Ensuring a Simple Graph A consequence of introducing the virtual edges from E v (S) in the forming of G SE is the potential for a virtual and a real edge to share the same endpoints. In this situation G SE would not represent a simple graph. With respect to G, the segment that the virtual edge represents and the real edge would form a cycle in G. As long as this cycle is not a Hamilton cycle, it is safe to remove the real edge, as any descendant point in the search space below the current one will never use the real edge in any Hamilton cycle found. In fact its removal would reduce the size of the tree formed below the current point in the search space. In algorithm it is to be assumed that ReduceGraph would ensure that a simple graph is returned, and any virtual edge takes precedence over a real edge Removal of Branching Edges As seen in algorithm 3.4.2, once a branching edge, e b, has been attempted, it is removed for the remaining branches at the current level in the search space. Since all edge combinations that may exist at that point in the search space which contain that branching edge will have been attempted, it must be removed. This removal may cause an inconsistent G SE. In this case the multipath method as currently defined, will fail at the first call to ForceEdges for each recursive call to the multipath method on the remaining branches. It would instead be better to detect if G SE is inconsistent once the recursive call to the multipath method returns for that branching edge. In algorithm 3.5.2, the
27 Chapter 3: The MultiPath Method 21 addition of a call to ForceEdges from within the while loop reflects this improvement. Algorithm 3.5.1: ForceEdges( G, S ) All parameters passed by value. comment: Returns the set { G, S, stop } where stop is a boolean flag indicating a stop condition. G ReduceGraph( G, S ) if IsStopCondition( G, S ) then return ( {,, true } ) while not IsConsistent(G) S S + GetForcedEdge(G) do G ReduceGraph( G, S ) if IsStopCondition( G, S ) then return ( {,, true } ) return ( { G, S, false } ) Algorithm 3.5.2: MultiPath( n, G, S ) All parameters passed by value. comment: Initially G = G, and S is empty. result = true G is Hamiltonian { G, S, stop } ForceEdges( G, S ) if stop then return ( n = E(S) ) v ChooseVertex(V (G)) while deg(v) 0 e b ChooseVertexEdge( v, E(G) ) G G e b do if MultiPath( n, G, S + e b ) then return ( true ) { G, S, stop } ForceEdges( G, S ) if stop then return ( n = E(S) ) return ( false )
28 Chapter 4 The Search Space To provide context on where the improvements described in this thesis are focused, this chapter illustrates the search space of the multipath method. The search trees used to describe the search space are assumed to be traversed in a depth first, left to right manner and are a reflection of the route generated by algorithm A hypothetical example of a search tree is presented in figure 4.1. The larger circular nodes represent the anchor points chosen and the smaller solid points represent vertices removed from G and placed into V in (S). The small diamond shaped leaves of the search tree represent the occurrence of a stopping condition. Anchor points that exist close to the extremities of the search tree are referred to as leaf nodes. A leaf node is an anchor point in the tree that only contains leaves as descendants. The edges joining points in the search tree do not correspond to edges added to E(S). The dashed edges between points in the tree do however indicate that a 22
29 Chapter 4: The Search Space 23 branching edge was chosen at that point in the search space. The rightmost solid edge descending out of an anchor point in the search tree represents an inconsistent state occurring due to the removal of a branching edge from G. 4.1 Example: Petersen Graph The search tree for the nonhamiltonian Petersen graph is shown in this example. This graph is used as an example because it terminates after only finding six stopping conditions. Figure 4.2 represents the search tree for the Petersen graph. The labeled vertices on the drawing of the Petersen graph correspond to the labels on the search tree. In the case of the Petersen graph, each of the six leaves terminate with stop condition 1 being encountered. Table 4.1 describes the state of E(S) at each of the six leaves in the search tree moving from left to right. Note how the branching edges correspond to the anchor points from the tree, and how E(S) behaves like a stack when moving between the branching edges. In figure 4.3 the state of G is represented for each stable state after the branching edge has been added to E(S) for each branching edge down to the leftmost leaf. Note stop condition 1 is detected for vertex 4 after branching edge {2,3} has been added. Also note that virtual edge {8,9}, requires the removal of the corresponding real edge, leading to the addition of vertex 7 to V in (S). As a comparison to the first method presented for finding Hamilton cycles, this
30 Chapter 4: The Search Space 24 Table 4.1: E(S) at the leaves of search tree for the Petersen graph. Branching edges are bold. Edge # {1,3} {1,3} {1,3} {1,3} {1,7} {1,7} 2 {1,7} {1,7} {1,10} {1,10} {1,10} {1,10} 3 {9,10} {9,10} {7,8} {7,8} {2,3} {2,3} 4 {6,10} {6,10} {4,7} {4,7} {3,5} {3,5} 5 {2,3} {3,5} {2,3} {3,5} {2,4} {2,9} 6 {5,6} {2,4} {5,6} {2,4} {8,9} {4,7} 7 {5,8} {2,9} {5,8} {2,9} {9,10} {4,6} 8 {7,8} {5,6} {2,4} {9,10} {4,7} {5,6} example of the multipath method only generates 6 leaves, using only 5 points where a branching is directly controlled by the algorithm. The first method would have generated ( 15 10), or 3003 leaves, and many more branchings would have to be controlled directly by the algorithm.
31 Chapter 4: The Search Space 25 Figure 4.1: Hypothetical search tree generated during the search for Hamilton cycles for some unknown graph using the MultiPath method. Typically the tree generated would be extremely large and would not be practical to display.
32 Chapter 4: The Search Space Figure 4.2: Full search tree of the multipath method for the Petersen graph Figure 4.3: State of G after each branching edge down to the leftmost leaf.
33 Chapter 5 Considerations for Algorithm Design Before progressing further with the design of the multipath algorithm, some considerations with respect to data structures and implementation details for [Koc92] must first be mentioned. The implementation for [Koc92] is similar to what has already been introduced for the multipath method in algorithms and It is a recursive procedure that can be configured to either stop at the first Hamilton cycle found, or to visit each possible Hamilton cycle by examining the entire search space. If a Hamilton cycle is treated as a stopping condition for a branch instead of a stopping condition for the algorithm, this visiting operation is possible in the multipath method. 27
34 Chapter 5: Considerations for Algorithm Design Data Structures If each vertex is labeled with a positive integer value, it can be used both as an identifier and as an index in lookup tables, arrays and other data structures. The special identifier of 0 is reserved, and can have specific meaning depending on use. Typically this use will result in the 0 th entry from any table/array to be used either as a temporary store or go unused. Entries in a table/array structure that use the 0 value in an entry where a vertex identifier is expected typically mean the indexed value does not belong to a set tracked by the structure Adjacency Matrix and Lists Two ways to store the edges of a graph are by using either a matrix, refered to as an adjacency matrix, or a linked list construct, called an adjacency list. An adjacency matrix is an n x n data structure that uses the index of two vertices to determine the existence of an edge. An adjacency matrix however has two main drawbacks: it is slow to determine all of the edges incident to a given vertex and it takes O(n 2 ) of memory to store. A linked list has the drawback of not being able to quickly test if two vertices are adjacent. The adjacency list for a given vertex must be scanned until the other vertex is encountered. The benefit of an adjacency list is when the traversal of all edges of a given vertex is all that is required. Additionally with adjacency lists, the entire graph is stored in O(ε) space. In [Koc92] both of these structures are used, however as will be shown in later
35 Chapter 5: Considerations for Algorithm Design 29 chapters, there is need only for the adjacency lists Degree Values and Virtual Edges Storing the current degree value in a lookup table/array is extremely useful, as it avoids the overhead of recalculating them. Depending on the data structure used to represent edges, the time overhead of recalculating is at least O(deg(v)). A lookup table reduces this to O(1). The tradeoff here is that more memory is required to store the degree value of each vertex. One very useful aspect of maintaining the degree array, is that it becomes trivial to test if a vertex is still within the current G, as it must have a nonzero value in the array. With respect to the multipath method, the extra virtual edge that may exist for any vertex can be stored using an array of vertices. At any point in the search space, the state of E v (S) can be reflected by an array with either a 0 value for vertices not in S or a vertex value for the other end point of a virtual edge. As will be seen later, this way of representing the virtual edge is preferable to inserting a new edge into an adjacency list Segment and Cycle Storage One result of the work done in this thesis, is that it is unnecessary to store the current segments and partial cycles during the running of the algorithm. Instead only directly maintaining the stack of edges in E(S) is necessary, as both segment and cycles can be directly derived from the contents of E(S).
36 Chapter 5: Considerations for Algorithm Design 30 However, in [Koc92] maintaining them is an integral part of the algorithm. To this effect a single array of vertices is used for segments and two arrays of vertices are used to track the current partial and potential Hamilton cycle. For the segments, a mergefind like structure is maintained in the array. More on the mergefind structure can be found in [Wei95]. For the partial Hamilton cycle, the two arrays use the entries to point to the vertices to the left and to the right of a given vertex. 5.2 Reducing Time and Space Overhead As noted in the header comments for each of the previous algorithms described, procedure arguments are passed by value. The overhead required to pass variables by value increases the memory requirements by an order of magnitude. Additionally, passing by value implies that time must be spent copying data. The expected overhead of copying would be in the range of O(n + ε) per branching edge in the search space. To limit the time and space penalties of copying by value, [Koc92] uses an inplace reduction on G. This means that a reference to the attributes in G is available at all points during the running of the algorithm and the original state of G is not known until the algorithm finishes. Only the current reduction of G is known and is equivalent to that given by equation 3.4. This inplace reduction is referred to as G r. To accomplish this inplace reduction, there must be a way to reverse changes to G r at each point in the search space, so as to ensure that the state of the data for each function call is equivalent to that of the pass by value model. The method used
37 Chapter 5: Considerations for Algorithm Design 31 to restore G r for the work described in this thesis can be found in the next chapter and differs from the way it is done in [Koc92]. One of these differences is in the extent of removing the pass by value data. While limiting the expense of retaining a complete copy of the graph state per node, in [Koc92] there is still a memory overhead of O(n 2 ) consisting of degree information and segment information. This is the remaining data that is still passed by value during branching operations, with O(n) cost in time and space for each node. Without the inplace reduction, memory overhead would be O(n 3 ) in space. This remaining overhead is eliminated by the work described in this thesis and the entire state of the algorithm only requires O(n + ε) in space to function. 5.3 Detecting Stopping Conditions The detection of a stopping condition has very little overhead. The algorithm forces edges into E(S) one at a time, and a stopping condition can be detected while dealing with each edge. Assume the current forced edge is e. The second stopping condition is easy to detect by simply checking segment membership of each of the two vertices incident to e. If both vertices belong to the same segment, a cycle is forced and a stop flag is raised. This can be done with an time overhead of just O(1). The first stopping condition has slightly more overhead than the second. A forced vertex never has any more edges to remove from G r, but the other vertex v incident to e may already be an endpoint for another segment. In this case, v must be added to V in (S) and all remaining edges incident to v must be removed from G r. The other
38 Chapter 5: Considerations for Algorithm Design 32 vertices incident to each of these removed edges must have their degree values reduced by one. If the degree value for any of these vertices is reduced to one, a stopping condition has occurred. The overhead here is just O(deg(v)), per non forced vertex pushed into V in (S). 5.4 Tracking Forced Vertices Instead of scanning each vertex in G r for forced vertices each time the ForceEdges method is called, it is possible to record the current forced edges in a list for quick referencing later. As mentioned with detecting stopping conditions, changes to S all occur one edge at a time. When removing the edges incident to each new vertex in V in (S), the changes to the degree values for the other vertex can also be used to detect when a vertex has become forced. Each of these vertices can be added to a list for later processing. The list construct used in [Koc92] is a queue. In the implementation for the multipath algorithm for this thesis a stack is used instead. A stack was chosen because by marking the beginning of the stack with a 0 value and not using it, no length variable is needed. A pointer to the current position is all that is required when a stack is used in this way. As the order in which forced edges is unimportant with respect to the final consistent G r, any abstract data type for managing list addition and removal can be used here. The order in which forced vertices are removed from the list becomes important when trying to detect stopping conditions sooner and more sophisticated structures
39 Chapter 5: Considerations for Algorithm Design 33 could be used to enable this, however this is beyond the scope of the work done here and further work could yield some interesting results.
40 Chapter 6 Designing the MultiPath Algorithm Algorithms and used to describe the multipath method are enough to provide a broad recipe on how to go about creating a complete multipath algorithm. This chapter is focused on fully developing the key aspects of the algorithm with respect to efficiently managing G r and S, as well as the selection of anchor points. The implementation of the multipath algorithm resulting from the work described in this thesis was developed incrementally, as a series of refinements and data structure changes, each of which brought an increase in efficiency and speed. By studying the effects of each of the changes on various graphs, the techniques were continually improved, and new approaches suggested themselves. This chapter and the next represents the finalization of the work in this thesis on the stand alone portion of the multipath algorithm. Recall that G r was introduced in the previous chapter as a representation of G 34
41 Chapter 6: Designing the MultiPath Algorithm 35 from algorithm 3.5.1, with the difference being that it is the continuously changing instance of the original graph G that is not passed by value during the execution of the multipath algorithm. As mentioned in the last chapter, passing by value increases both time and space overhead to the algorithm that would be best left avoided if possible. In order to design an algorithm that completely removes the pass by value requirements of movement between consistent states of G r, the first section of this chapter is concerned with the mechanics of changes to S and G r during movement up and down the search space of the multipath algorithm. This also includes an improved algorithm for creating and extending the segments in S over the one used in [Koc92]. The final section of this chapter deals with the order in which anchor points are chosen. This can have a profound effect on the shape and size of the search space to be navigated by the algorithm. 6.1 Efficient Reduction and Recovery The reduction and recovery of G r between branching edges in the search space consumes the majority of the time spent running the algorithm. The improvements described in this section attempt to reduce the internal changes that are required when transforming a graph from one state to another, while additionally removing the remaining pass by value requirements from [Koc92]. By changing how edges are added to S it is possible to reverse the changes to G r as well as restore the data structures storing segment and degree information, subsequently reducing the memory footprint required by this portion of the algorithm
42 Chapter 6: Designing the MultiPath Algorithm 36 by a factor of n. This results in a memory footprint of O(n+ε) for the entire algorithm. Additionally the total time overhead of managing G r is reduced to O( S), where S is the number of edges added to E(S) between branching edges. This is instead of the O(n + S) from the previous version. Section describes a different way of creating and extending segments in S that improves on what has been used previously. The improvement here over [Koc92] is difficult to quantify as it is heavily dependent on the structure of the graphs searched, however at worst it will be equivalent in steps required. Section describes how removed edges from G r are managed, and section describes how the state of G r is restored. The process of restoring G r used here is the reason for the O( S) claim Extending Segments Up to this point changes to segments in S occur one edge at a time. In this way there are three possible results when adding a forced or branching edge to E(S); either a segment is created or extended, or two segments will be merged into a single segment. Each time E(S), E v (S) and G r must be updated to reflect the new reduction. The process is repeated until no more forced edges remain in G r. Extending Segments from Forced Vertices via Paths The new approach changes focus from single edges to paths that can be extended from forced vertices in G r. Extending segments using a branching edge and its corresponding anchor point is a special case of this approach and is described at the end of
43 Chapter 6: Designing the MultiPath Algorithm 37 P u P v e S i 1 u v e S i+1 v e S i G r Figure 6.1: Segments S i 1, S i, and S i+1 before extension of Si via forced vertex v. Forced vertices are represented by the solid symbols. The virtual edge {u,v} representing S i is labeled with a e S i and the other virtual edges are labeled likewise. this section. Let v be the next forced vertex to be processed. If v is the endpoint of some segment, S i S, virtual edge {u,v} represents this segment. Let P v be the first path to be extended into G r that originates at v. The first edge in P v is the real edge, {v,v }. This edge is added to E(S). Let P u be the second path to be extended into G r that originates at v, but proceeds in the opposite direction. If v is the endpoint of a segment, let the first edge in P u be the virtual edge {u,v}. If v is not the endpoint of a segment, let the first edge in P u be the real edge {u,v}, and ensure it is added to E(S). Initially let u = u. During the growth of P v and P u, the shared endpoint v remains fixed, while v and u are updated to indicate the new endpoints. Figure 6.1 illustrates this initial configuration on a cross section of an example G r. The goal is to form a new segment, Si, represented by the following: S i = P u + P v (6.1)
2.3 Scheduling jobs on identical parallel machines
2.3 Scheduling jobs on identical parallel machines There are jobs to be processed, and there are identical machines (running in parallel) to which each job may be assigned Each job = 1,,, must be processed
More information1 Basic Definitions and Concepts in Graph Theory
CME 305: Discrete Mathematics and Algorithms 1 Basic Definitions and Concepts in Graph Theory A graph G(V, E) is a set V of vertices and a set E of edges. In an undirected graph, an edge is an unordered
More informationGraphs and Network Flows IE411 Lecture 1
Graphs and Network Flows IE411 Lecture 1 Dr. Ted Ralphs IE411 Lecture 1 1 References for Today s Lecture Required reading Sections 17.1, 19.1 References AMO Chapter 1 and Section 2.1 and 2.2 IE411 Lecture
More informationV. Adamchik 1. Graph Theory. Victor Adamchik. Fall of 2005
V. Adamchik 1 Graph Theory Victor Adamchik Fall of 2005 Plan 1. Basic Vocabulary 2. Regular graph 3. Connectivity 4. Representing Graphs Introduction A.Aho and J.Ulman acknowledge that Fundamentally, computer
More informationSolutions to Exercises 8
Discrete Mathematics Lent 2009 MA210 Solutions to Exercises 8 (1) Suppose that G is a graph in which every vertex has degree at least k, where k 1, and in which every cycle contains at least 4 vertices.
More informationSocial Media Mining. Graph Essentials
Graph Essentials Graph Basics Measures Graph and Essentials Metrics 2 2 Nodes and Edges A network is a graph nodes, actors, or vertices (plural of vertex) Connections, edges or ties Edge Node Measures
More information1 Digraphs. Definition 1
1 Digraphs Definition 1 Adigraphordirected graphgisatriplecomprisedofavertex set V(G), edge set E(G), and a function assigning each edge an ordered pair of vertices (tail, head); these vertices together
More informationGraph. Consider a graph, G in Fig Then the vertex V and edge E can be represented as:
Graph A graph G consist of 1. Set of vertices V (called nodes), (V = {v1, v2, v3, v4...}) and 2. Set of edges E (i.e., E {e1, e2, e3...cm} A graph can be represents as G = (V, E), where V is a finite and
More informationAnalysis of Algorithms, I
Analysis of Algorithms, I CSOR W4231.002 Eleni Drinea Computer Science Department Columbia University Thursday, February 26, 2015 Outline 1 Recap 2 Representing graphs 3 Breadthfirst search (BFS) 4 Applications
More informationPage 1. CSCE 310J Data Structures & Algorithms. CSCE 310J Data Structures & Algorithms. P, NP, and NPComplete. PolynomialTime Algorithms
CSCE 310J Data Structures & Algorithms P, NP, and NPComplete Dr. Steve Goddard goddard@cse.unl.edu CSCE 310J Data Structures & Algorithms Giving credit where credit is due:» Most of the lecture notes
More information2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]
Code No: R05220502 Set No. 1 1. (a) Describe the performance analysis in detail. (b) Show that f 1 (n)+f 2 (n) = 0(max(g 1 (n), g 2 (n)) where f 1 (n) = 0(g 1 (n)) and f 2 (n) = 0(g 2 (n)). [8+8] 2. (a)
More informationTheorem A graph T is a tree if, and only if, every two distinct vertices of T are joined by a unique path.
Chapter 3 Trees Section 3. Fundamental Properties of Trees Suppose your city is planning to construct a rapid rail system. They want to construct the most economical system possible that will meet the
More informationCOT5405 Analysis of Algorithms Homework 3 Solutions
COT0 Analysis of Algorithms Homework 3 Solutions. Prove or give a counter example: (a) In the textbook, we have two routines for graph traversal  DFS(G) and BFS(G,s)  where G is a graph and s is any
More informationComplexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar
Complexity Theory IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar Outline Goals Computation of Problems Concepts and Definitions Complexity Classes and Problems Polynomial Time Reductions Examples
More informationCMSC 451: Graph Properties, DFS, BFS, etc.
CMSC 451: Graph Properties, DFS, BFS, etc. Slides By: Carl Kingsford Department of Computer Science University of Maryland, College Park Based on Chapter 3 of Algorithm Design by Kleinberg & Tardos. Graphs
More information12 Abstract Data Types
12 Abstract Data Types 12.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT).
More informationWhy? A central concept in Computer Science. Algorithms are ubiquitous.
Analysis of Algorithms: A Brief Introduction Why? A central concept in Computer Science. Algorithms are ubiquitous. Using the Internet (sending email, transferring files, use of search engines, online
More informationOutline. NPcompleteness. When is a problem easy? When is a problem hard? Today. Euler Circuits
Outline NPcompleteness Examples of Easy vs. Hard problems Euler circuit vs. Hamiltonian circuit Shortest Path vs. Longest Path 2pairs sum vs. general Subset Sum Reducing one problem to another Clique
More informationInformatique Fondamentale IMA S8
Informatique Fondamentale IMA S8 Cours 4 : graphs, problems and algorithms on graphs, (notions of) NP completeness Laure Gonnord http://laure.gonnord.org/pro/teaching/ Laure.Gonnord@polytechlille.fr Université
More informationIE 680 Special Topics in Production Systems: Networks, Routing and Logistics*
IE 680 Special Topics in Production Systems: Networks, Routing and Logistics* Rakesh Nagi Department of Industrial Engineering University at Buffalo (SUNY) *Lecture notes from Network Flows by Ahuja, Magnanti
More informationChapter 4: Trees. 2. Theorem: Let T be a graph with n vertices. Then the following statements are equivalent:
9 Properties of Trees. Definitions: Chapter 4: Trees forest  a graph that contains no cycles tree  a connected forest. Theorem: Let T be a graph with n vertices. Then the following statements are equivalent:
More informationThe origins of graph theory are humble, even frivolous. Biggs, E. K. Lloyd, and R. J. Wilson)
Chapter 11 Graph Theory The origins of graph theory are humble, even frivolous. Biggs, E. K. Lloyd, and R. J. Wilson) (N. Let us start with a formal definition of what is a graph. Definition 72. A graph
More informationDiscrete Mathematics & Mathematical Reasoning Chapter 10: Graphs
Discrete Mathematics & Mathematical Reasoning Chapter 10: Graphs Kousha Etessami U. of Edinburgh, UK Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 1 / 13 Overview Graphs and Graph
More informationCOLORED GRAPHS AND THEIR PROPERTIES
COLORED GRAPHS AND THEIR PROPERTIES BEN STEVENS 1. Introduction This paper is concerned with the upper bound on the chromatic number for graphs of maximum vertex degree under three different sets of coloring
More informationChapter 4. Trees. 4.1 Basics
Chapter 4 Trees 4.1 Basics A tree is a connected graph with no cycles. A forest is a collection of trees. A vertex of degree one, particularly in a tree, is called a leaf. Trees arise in a variety of applications.
More informationMidterm Practice Problems
6.042/8.062J Mathematics for Computer Science October 2, 200 Tom Leighton, Marten van Dijk, and Brooke Cowan Midterm Practice Problems Problem. [0 points] In problem set you showed that the nand operator
More informationComputational Geometry
Motivation 1 Motivation Polygons and visibility Visibility in polygons Triangulation Proof of the Art gallery theorem Two points in a simple polygon can see each other if their connecting line segment
More informationPlanar Tree Transformation: Results and Counterexample
Planar Tree Transformation: Results and Counterexample Selim G Akl, Kamrul Islam, and Henk Meijer School of Computing, Queen s University Kingston, Ontario, Canada K7L 3N6 Abstract We consider the problem
More informationTwo General Methods to Reduce Delay and Change of Enumeration Algorithms
ISSN 13465597 NII Technical Report Two General Methods to Reduce Delay and Change of Enumeration Algorithms Takeaki Uno NII2003004E Apr.2003 Two General Methods to Reduce Delay and Change of Enumeration
More informationChapter 6 Planarity. Section 6.1 Euler s Formula
Chapter 6 Planarity Section 6.1 Euler s Formula In Chapter 1 we introduced the puzzle of the three houses and the three utilities. The problem was to determine if we could connect each of the three utilities
More informationZachary Monaco Georgia College Olympic Coloring: Go For The Gold
Zachary Monaco Georgia College Olympic Coloring: Go For The Gold Coloring the vertices or edges of a graph leads to a variety of interesting applications in graph theory These applications include various
More informationChapter 2. Basic Terminology and Preliminaries
Chapter 2 Basic Terminology and Preliminaries 6 Chapter 2. Basic Terminology and Preliminaries 7 2.1 Introduction This chapter is intended to provide all the fundamental terminology and notations which
More informationSection Summary. Introduction to Graphs Graph Taxonomy Graph Models
Chapter 10 Chapter Summary Graphs and Graph Models Graph Terminology and Special Types of Graphs Representing Graphs and Graph Isomorphism Connectivity Euler and Hamiltonian Graphs ShortestPath Problems
More informationCS268: Geometric Algorithms Handout #5 Design and Analysis Original Handout #15 Stanford University Tuesday, 25 February 1992
CS268: Geometric Algorithms Handout #5 Design and Analysis Original Handout #15 Stanford University Tuesday, 25 February 1992 Original Lecture #6: 28 January 1991 Topics: Triangulating Simple Polygons
More informationComplexity Classes P and NP
Complexity Classes P and NP MATH 3220 Supplemental Presentation by John Aleshunas The cure for boredom is curiosity. There is no cure for curiosity Dorothy Parker Computational Complexity Theory In computer
More informationNetwork (Tree) Topology Inference Based on Prüfer Sequence
Network (Tree) Topology Inference Based on Prüfer Sequence C. Vanniarajan and Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology Madras Chennai 600036 vanniarajanc@hcl.in,
More informationOn the Relationship between Classes P and NP
Journal of Computer Science 8 (7): 10361040, 2012 ISSN 15493636 2012 Science Publications On the Relationship between Classes P and NP Anatoly D. Plotnikov Department of Computer Systems and Networks,
More informationDiscrete Mathematics Problems
Discrete Mathematics Problems William F. Klostermeyer School of Computing University of North Florida Jacksonville, FL 32224 Email: wkloster@unf.edu Contents 0 Preface 3 1 Logic 5 1.1 Basics...............................
More informationHome Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit
Data Structures Page 1 of 24 A.1. Arrays (Vectors) nelement vector start address + ielementsize 0 +1 +2 +3 +4... +n1 start address continuous memory block static, if size is known at compile time dynamic,
More informationCombinatorics: The Fine Art of Counting
Combinatorics: The Fine Art of Counting Week 9 Lecture Notes Graph Theory For completeness I have included the definitions from last week s lecture which we will be using in today s lecture along with
More informationComputer Algorithms. NPComplete Problems. CISC 4080 Yanjun Li
Computer Algorithms NPComplete Problems NPcompleteness The quest for efficient algorithms is about finding clever ways to bypass the process of exhaustive search, using clues from the input in order
More informationExponential time algorithms for graph coloring
Exponential time algorithms for graph coloring Uriel Feige Lecture notes, March 14, 2011 1 Introduction Let [n] denote the set {1,..., k}. A klabeling of vertices of a graph G(V, E) is a function V [k].
More informationThe Classes P and NP
The Classes P and NP We now shift gears slightly and restrict our attention to the examination of two families of problems which are very important to computer scientists. These families constitute the
More information3. Eulerian and Hamiltonian Graphs
3. Eulerian and Hamiltonian Graphs There are many games and puzzles which can be analysed by graph theoretic concepts. In fact, the two early discoveries which led to the existence of graphs arose from
More informationComplexity and Completeness of Finding Another Solution and Its Application to Puzzles
yato@is.s.utokyo.ac.jp seta@is.s.utokyo.ac.jp Π (ASP) Π x s x s ASP Ueda Nagao n nasp parsimonious ASP ASP NP Complexity and Completeness of Finding Another Solution and Its Application to Puzzles Takayuki
More informationMemoization/Dynamic Programming. The String reconstruction problem. CS125 Lecture 5 Fall 2016
CS125 Lecture 5 Fall 2016 Memoization/Dynamic Programming Today s lecture discusses memoization, which is a method for speeding up algorithms based on recursion, by using additional memory to remember
More informationInstitut für Informatik Lehrstuhl Theoretische Informatik I / Komplexitätstheorie. An Iterative Compression Algorithm for Vertex Cover
FriedrichSchillerUniversität Jena Institut für Informatik Lehrstuhl Theoretische Informatik I / Komplexitätstheorie Studienarbeit An Iterative Compression Algorithm for Vertex Cover von Thomas Peiselt
More informationLecture 2: The Complexity of Some Problems
IAS/PCMI Summer Session 2000 Clay Mathematics Undergraduate Program Basic Course on Computational Complexity Lecture 2: The Complexity of Some Problems David Mix Barrington and Alexis Maciel July 18, 2000
More informationOn the kpath cover problem for cacti
On the kpath cover problem for cacti Zemin Jin and Xueliang Li Center for Combinatorics and LPMC Nankai University Tianjin 300071, P.R. China zeminjin@eyou.com, x.li@eyou.com Abstract In this paper we
More informationMathematics for Algorithm and System Analysis
Mathematics for Algorithm and System Analysis for students of computer and computational science Edward A. Bender S. Gill Williamson c Edward A. Bender & S. Gill Williamson 2005. All rights reserved. Preface
More information10. Graph Matrices Incidence Matrix
10 Graph Matrices Since a graph is completely determined by specifying either its adjacency structure or its incidence structure, these specifications provide far more efficient ways of representing a
More information5.1 Bipartite Matching
CS787: Advanced Algorithms Lecture 5: Applications of Network Flow In the last lecture, we looked at the problem of finding the maximum flow in a graph, and how it can be efficiently solved using the FordFulkerson
More informationHomework 15 Solutions
PROBLEM ONE (Trees) Homework 15 Solutions 1. Recall the definition of a tree: a tree is a connected, undirected graph which has no cycles. Which of the following definitions are equivalent to this definition
More informationComputational Geometry
Motivation Motivation Polygons and visibility Visibility in polygons Triangulation Proof of the Art gallery theorem Two points in a simple polygon can see each other if their connecting line segment is
More informationOne last point: we started off this book by introducing another famously hard search problem:
S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani 261 Factoring One last point: we started off this book by introducing another famously hard search problem: FACTORING, the task of finding all prime factors
More information(Refer Slide Time: 01:35)
Artificial Intelligence Prof. Sudeshna Sarkar Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture  6 Informed Search 2 Today we start our 6 th lecture. This
More informationSmall Maximal Independent Sets and Faster Exact Graph Coloring
Small Maximal Independent Sets and Faster Exact Graph Coloring David Eppstein Univ. of California, Irvine Dept. of Information and Computer Science The Exact Graph Coloring Problem: Given an undirected
More informationData Structure [Question Bank]
Unit I (Analysis of Algorithms) 1. What are algorithms and how they are useful? 2. Describe the factor on best algorithms depends on? 3. Differentiate: Correct & Incorrect Algorithms? 4. Write short note:
More informationIntroduction to Logic in Computer Science: Autumn 2006
Introduction to Logic in Computer Science: Autumn 2006 Ulle Endriss Institute for Logic, Language and Computation University of Amsterdam Ulle Endriss 1 Plan for Today Now that we have a basic understanding
More informationSCAN: A Structural Clustering Algorithm for Networks
SCAN: A Structural Clustering Algorithm for Networks Xiaowei Xu, Nurcan Yuruk, Zhidan Feng (University of Arkansas at Little Rock) Thomas A. J. Schweiger (Acxiom Corporation) Networks scaling: #edges connected
More informationIntroduction to computer science
Introduction to computer science Michael A. Nielsen University of Queensland Goals: 1. Introduce the notion of the computational complexity of a problem, and define the major computational complexity classes.
More informationVector storage and access; algorithms in GIS. This is lecture 6
Vector storage and access; algorithms in GIS This is lecture 6 Vector data storage and access Vectors are built from points, line and areas. (x,y) Surface: (x,y,z) Vector data access Access to vector
More informationThe UnionFind Problem Kruskal s algorithm for finding an MST presented us with a problem in datastructure design. As we looked at each edge,
The UnionFind Problem Kruskal s algorithm for finding an MST presented us with a problem in datastructure design. As we looked at each edge, cheapest first, we had to determine whether its two endpoints
More informationMeasuring the Performance of an Agent
25 Measuring the Performance of an Agent The rational agent that we are aiming at should be successful in the task it is performing To assess the success we need to have a performance measure What is rational
More informationCIS 700: algorithms for Big Data
CIS 700: algorithms for Big Data Lecture 6: Graph Sketching Slides at http://grigory.us/bigdataclass.html Grigory Yaroslavtsev http://grigory.us Sketching Graphs? We know how to sketch vectors: v Mv
More informationHomework MA 725 Spring, 2012 C. Huneke SELECTED ANSWERS
Homework MA 725 Spring, 2012 C. Huneke SELECTED ANSWERS 1.1.25 Prove that the Petersen graph has no cycle of length 7. Solution: There are 10 vertices in the Petersen graph G. Assume there is a cycle C
More informationThe LCA Problem Revisited
The LA Problem Revisited Michael A. Bender Martín Faracholton SUNY Stony Brook Rutgers University May 16, 2000 Abstract We present a very simple algorithm for the Least ommon Ancestor problem. We thus
More informationSymbol Tables. Introduction
Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The
More informationSubgraph Patterns: Network Motifs and Graphlets. Pedro Ribeiro
Subgraph Patterns: Network Motifs and Graphlets Pedro Ribeiro Analyzing Complex Networks We have been talking about extracting information from networks Some possible tasks: General Patterns Ex: scalefree,
More informationGRAPH THEORY and APPLICATIONS. Trees
GRAPH THEORY and APPLICATIONS Trees Properties Tree: a connected graph with no cycle (acyclic) Forest: a graph with no cycle Paths are trees. Star: A tree consisting of one vertex adjacent to all the others.
More informationState Space Problem Definition
Blind Search State Space Problem Definition One widely used way to describe problems is by listing or describing all possible states. Solving a problem means moving through the state space from a start
More informationState Space Representation and Search
1. Introduction In this section we examine the concept of a state space and the different searches that can be used to explore the search space in order to find a solution. Before an AI problem can be
More informationroot node level: internal node edge leaf node CS@VT Data Structures & Algorithms 20002009 McQuain
inary Trees 1 A binary tree is either empty, or it consists of a node called the root together with two binary trees called the left subtree and the right subtree of the root, which are disjoint from each
More informationNotes on NP Completeness
Notes on NP Completeness Rich Schwartz November 10, 2013 1 Overview Here are some notes which I wrote to try to understand what NP completeness means. Most of these notes are taken from Appendix B in Douglas
More informationCSC2420 Spring 2015: Lecture 3
CSC2420 Spring 2015: Lecture 3 Allan Borodin January 22, 2015 1 / 1 Announcements and todays agenda Assignment 1 due next Thursday. I may add one or two additional questions today or tomorrow. Todays agenda
More informationGENERATING THE FIBONACCI CHAIN IN O(log n) SPACE AND O(n) TIME J. Patera
ˆ ˆŠ Œ ˆ ˆ Œ ƒ Ÿ 2002.. 33.. 7 Š 539.12.01 GENERATING THE FIBONACCI CHAIN IN O(log n) SPACE AND O(n) TIME J. Patera Department of Mathematics, Faculty of Nuclear Science and Physical Engineering, Czech
More informationIntroduction to Algorithms. Part 3: P, NP Hard Problems
Introduction to Algorithms Part 3: P, NP Hard Problems 1) Polynomial Time: P and NP 2) NPCompleteness 3) Dealing with Hard Problems 4) Lower Bounds 5) Books c Wayne Goddard, Clemson University, 2004 Chapter
More information1 Definitions. Supplementary Material for: Digraphs. Concept graphs
Supplementary Material for: van Rooij, I., Evans, P., Müller, M., Gedge, J. & Wareham, T. (2008). Identifying Sources of Intractability in Cognitive Models: An Illustration using Analogical Structure Mapping.
More informationGraph Theory. Introduction. Distance in Graphs. Trees. Isabela Drămnesc UVT. Computer Science Department, West University of Timişoara, Romania
Graph Theory Introduction. Distance in Graphs. Trees Isabela Drămnesc UVT Computer Science Department, West University of Timişoara, Romania November 2016 Isabela Drămnesc UVT Graph Theory and Combinatorics
More informationPartitioning edgecoloured complete graphs into monochromatic cycles and paths
arxiv:1205.5492v1 [math.co] 24 May 2012 Partitioning edgecoloured complete graphs into monochromatic cycles and paths Alexey Pokrovskiy Departement of Mathematics, London School of Economics and Political
More informationLong questions answer Advanced Mathematics for Computer Application If P= , find BT. 19. If B = 1 0, find 2B and 3B.
Unit1: Matrix Algebra Short questions answer 1. What is Matrix? 2. Define the following terms : a) Elements matrix b) Row matrix c) Column matrix d) Diagonal matrix e) Scalar matrix f) Unit matrix OR
More informationSpectral graph theory
Spectral graph theory Uri Feige January 2010 1 Background With every graph (or digraph) one can associate several different matrices. We have already seen the vertexedge incidence matrix, the Laplacian
More informationGuessing Game: NPComplete?
Guessing Game: NPComplete? 1. LONGESTPATH: Given a graph G = (V, E), does there exists a simple path of length at least k edges? YES 2. SHORTESTPATH: Given a graph G = (V, E), does there exists a simple
More informationScheduling Home Health Care with Separating Benders Cuts in Decision Diagrams
Scheduling Home Health Care with Separating Benders Cuts in Decision Diagrams André Ciré University of Toronto John Hooker Carnegie Mellon University INFORMS 2014 Home Health Care Home health care delivery
More information(a) (b) (c) Figure 1 : Graphs, multigraphs and digraphs. If the vertices of the leftmost figure are labelled {1, 2, 3, 4} in clockwise order from
4 Graph Theory Throughout these notes, a graph G is a pair (V, E) where V is a set and E is a set of unordered pairs of elements of V. The elements of V are called vertices and the elements of E are called
More informationCSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) 3 4 4 7 5 9 6 16 7 8 8 4 9 8 10 4 Total 92.
Name: Email ID: CSE 326, Data Structures Section: Sample Final Exam Instructions: The exam is closed book, closed notes. Unless otherwise stated, N denotes the number of elements in the data structure
More information8.1 Min Degree Spanning Tree
CS880: Approximations Algorithms Scribe: Siddharth Barman Lecturer: Shuchi Chawla Topic: Min Degree Spanning Tree Date: 02/15/07 In this lecture we give a local search based algorithm for the Min Degree
More informationLoad Balancing. Load Balancing 1 / 24
Load Balancing Backtracking, branch & bound and alphabeta pruning: how to assign work to idle processes without much communication? Additionally for alphabeta pruning: implementing the youngbrotherswait
More informationThe relationship of a trees to a graph is very important in solving many problems in Maths and Computer Science
Trees Mathematically speaking trees are a special class of a graph. The relationship of a trees to a graph is very important in solving many problems in Maths and Computer Science However, in computer
More informationAsking Hard Graph Questions. Paul Burkhardt. February 3, 2014
Beyond Watson: Predictive Analytics and Big Data U.S. National Security Agency Research Directorate  R6 Technical Report February 3, 2014 300 years before Watson there was Euler! The first (Jeopardy!)
More informationLecture Notes on Spanning Trees
Lecture Notes on Spanning Trees 15122: Principles of Imperative Computation Frank Pfenning Lecture 26 April 26, 2011 1 Introduction In this lecture we introduce graphs. Graphs provide a uniform model
More informationA Formal Model of Program Dependences and Its Implications for Software Testing, Debugging, and Maintenance
A Formal Model of Program Dependences and Its Implications for Software Testing, Debugging, and Maintenance Andy Podgurski Lori A. Clarke Computer Engineering & Science Department Case Western Reserve
More information4 Basics of Trees. Petr Hliněný, FI MU Brno 1 FI: MA010: Trees and Forests
4 Basics of Trees Trees, actually acyclic connected simple graphs, are among the simplest graph classes. Despite their simplicity, they still have rich structure and many useful application, such as in
More informationUniversality in the theory of algorithms and computer science
Universality in the theory of algorithms and computer science Alexander Shen Computational models The notion of computable function was introduced in 1930ies. Simplifying (a rather interesting and puzzling)
More information/ Approximation Algorithms Lecturer: Michael Dinitz Topic: Steiner Tree and TSP Date: 01/29/15 Scribe: Katie Henry
600.469 / 600.669 Approximation Algorithms Lecturer: Michael Dinitz Topic: Steiner Tree and TSP Date: 01/29/15 Scribe: Katie Henry 2.1 Steiner Tree Definition 2.1.1 In the Steiner Tree problem the input
More informationG.H. Raisoni College of Engineering, Nagpur. Department of Information Technology
Practical List 1) WAP to implement line generation using DDA algorithm 2) WAP to implement line using Bresenham s line generation algorithm. 3) WAP to generate circle using circle generation algorithm
More information5. Binary objects labeling
Image Processing  Laboratory 5: Binary objects labeling 1 5. Binary objects labeling 5.1. Introduction In this laboratory an object labeling algorithm which allows you to label distinct objects from a
More informationLinear Programming Problems
Linear Programming Problems Linear programming problems come up in many applications. In a linear programming problem, we have a function, called the objective function, which depends linearly on a number
More informationBoolean Representations and Combinatorial Equivalence
Chapter 2 Boolean Representations and Combinatorial Equivalence This chapter introduces different representations of Boolean functions. It then discuss the applications of these representations for proving
More informationeach college c i C has a capacity q i  the maximum number of students it will admit
n colleges in a set C, m applicants in a set A, where m is much larger than n. each college c i C has a capacity q i  the maximum number of students it will admit each college c i has a strict order i
More information