Path: blob/master/sage/graphs/planarity/graphK4Search.private.h
4097 views
#ifndef GRAPH_K4SEARCH_PRIVATE_H1#define GRAPH_K4SEARCH_PRIVATE_H23/*4Planarity-Related Graph Algorithms Project5Copyright (c) 1997-2010, John M. Boyer6All rights reserved. Includes a reference implementation of the following:78* John M. Boyer. "Simplified O(n) Algorithms for Planar Graph Embedding,9Kuratowski Subgraph Isolation, and Related Problems". Ph.D. Dissertation,10University of Victoria, 2001.1112* John M. Boyer and Wendy J. Myrvold. "On the Cutting Edge: Simplified O(n)13Planarity by Edge Addition". Journal of Graph Algorithms and Applications,14Vol. 8, No. 3, pp. 241-273, 2004.1516* John M. Boyer. "A New Method for Efficiently Generating Planar Graph17Visibility Representations". In P. Eades and P. Healy, editors,18Proceedings of the 13th International Conference on Graph Drawing 2005,19Lecture Notes Comput. Sci., Volume 3843, pp. 508-511, Springer-Verlag, 2006.2021Redistribution and use in source and binary forms, with or without modification,22are permitted provided that the following conditions are met:2324* Redistributions of source code must retain the above copyright notice, this25list of conditions and the following disclaimer.2627* Redistributions in binary form must reproduce the above copyright notice, this28list of conditions and the following disclaimer in the documentation and/or29other materials provided with the distribution.3031* Neither the name of the Planarity-Related Graph Algorithms Project nor the names32of its contributors may be used to endorse or promote products derived from this33software without specific prior written permission.3435THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"36AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE37IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE38DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR39ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES40(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;41LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON42ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT43(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS44SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.45*/4647#include "graph.h"4849#ifdef __cplusplus50extern "C" {51#endif5253/* Additional equipment for each graph node (edge arc or vertex)5455pathConnector:56Used in the edge records (arcs) of a reduction edge to indicate the57endpoints of a path that has been reduced from (removed from) the58embedding so that the search for a K4 can continue.59We only need a pathConnector because we reduce subgraphs that are60separable by a 2-cut, so they can contribute at most one path to a61subgraph homeomorphic to K4, if one is indeed found. Thus, we first62delete all edges except for the desired path(s), then we reduce any63retained path to an edge.6465subtree:66Used in each forward arc (V, D) to indicate the DFS child C of V whose67DFS subtree contains the DFS descendant endpoint D of the forward arc.68This helps to efficiently find C when (V, D) is embedded so that the69p2dFwdArcCount of C can be decremented.70In order to efficiently calculate this value in preprocessing, the71fwdArcList of each vertex is sorted by descendant endpoint DFS number,72and the sortedDFSChildList of each vertex is computed. This enables73the subtree settings to be made with a single pass simultaneously74through the fwdArcList and sortedDFSChildList. See the implementation75of CreateDFSTreeEmbedding for details.76*/77typedef struct78{79int pathConnector, subtree;80} K4Search_GraphNode;8182typedef K4Search_GraphNode * K4Search_GraphNodeP;8384/* Additional equipment for each vertex8586p2dFwdArcCount:87During preprocessing, for each vertex we need to know how many forward arcs88there are from the DFS parent of the vertex to the DFS descendants of the89vertex. As each forward arc is embedded, we decrement this count. When this90count reaches zero, we remove the vertex from the sortedDFSChildList of its91parent.9293sortedDFSChildList:94During preprocessing, we need a list of the DFS children for each vertex,95sorted by their DFS numbers. The core planarity/outerplanarity algorithm96calculates a separatedDFSChildList that is sorted by the children's Lowpoints.97During processing, a child is removed from the sortedDFSChildList of its98parent when the p2dFwdArcCount of the child reaches zero. Thus, this list99indicates which subtree children of a vertex still contain unresolved100pertinence (unembedded forward arcs). The main search for K4 homeomorphs101uses this list to efficiently determine the portion of the graph in which102to either find a K4 or to perform reductions than enable more forward arcs103to be embedded.104*/105typedef struct106{107int p2dFwdArcCount, sortedDFSChildList;108} K4Search_VertexRec;109110typedef K4Search_VertexRec * K4Search_VertexRecP;111112113typedef struct114{115// Helps distinguish initialize from re-initialize116int initialized;117118// The graph that this context augments119graphP theGraph;120121// Additional graph-level equipment122listCollectionP sortedDFSChildLists;123124// Parallel array for additional graph node level equipment125K4Search_GraphNodeP G;126127// Parallel array for additional vertex level equipment128K4Search_VertexRecP V;129130// Overloaded function pointers131graphFunctionTable functions;132133} K4SearchContext;134135#ifdef __cplusplus136}137#endif138139#endif140141142