Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/graphs/planarity/graphK4Search.private.h
4097 views
1
#ifndef GRAPH_K4SEARCH_PRIVATE_H
2
#define GRAPH_K4SEARCH_PRIVATE_H
3
4
/*
5
Planarity-Related Graph Algorithms Project
6
Copyright (c) 1997-2010, John M. Boyer
7
All rights reserved. Includes a reference implementation of the following:
8
9
* John M. Boyer. "Simplified O(n) Algorithms for Planar Graph Embedding,
10
Kuratowski Subgraph Isolation, and Related Problems". Ph.D. Dissertation,
11
University of Victoria, 2001.
12
13
* John M. Boyer and Wendy J. Myrvold. "On the Cutting Edge: Simplified O(n)
14
Planarity by Edge Addition". Journal of Graph Algorithms and Applications,
15
Vol. 8, No. 3, pp. 241-273, 2004.
16
17
* John M. Boyer. "A New Method for Efficiently Generating Planar Graph
18
Visibility Representations". In P. Eades and P. Healy, editors,
19
Proceedings of the 13th International Conference on Graph Drawing 2005,
20
Lecture Notes Comput. Sci., Volume 3843, pp. 508-511, Springer-Verlag, 2006.
21
22
Redistribution and use in source and binary forms, with or without modification,
23
are permitted provided that the following conditions are met:
24
25
* Redistributions of source code must retain the above copyright notice, this
26
list of conditions and the following disclaimer.
27
28
* Redistributions in binary form must reproduce the above copyright notice, this
29
list of conditions and the following disclaimer in the documentation and/or
30
other materials provided with the distribution.
31
32
* Neither the name of the Planarity-Related Graph Algorithms Project nor the names
33
of its contributors may be used to endorse or promote products derived from this
34
software without specific prior written permission.
35
36
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
37
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
40
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
41
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
43
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46
*/
47
48
#include "graph.h"
49
50
#ifdef __cplusplus
51
extern "C" {
52
#endif
53
54
/* Additional equipment for each graph node (edge arc or vertex)
55
56
pathConnector:
57
Used in the edge records (arcs) of a reduction edge to indicate the
58
endpoints of a path that has been reduced from (removed from) the
59
embedding so that the search for a K4 can continue.
60
We only need a pathConnector because we reduce subgraphs that are
61
separable by a 2-cut, so they can contribute at most one path to a
62
subgraph homeomorphic to K4, if one is indeed found. Thus, we first
63
delete all edges except for the desired path(s), then we reduce any
64
retained path to an edge.
65
66
subtree:
67
Used in each forward arc (V, D) to indicate the DFS child C of V whose
68
DFS subtree contains the DFS descendant endpoint D of the forward arc.
69
This helps to efficiently find C when (V, D) is embedded so that the
70
p2dFwdArcCount of C can be decremented.
71
In order to efficiently calculate this value in preprocessing, the
72
fwdArcList of each vertex is sorted by descendant endpoint DFS number,
73
and the sortedDFSChildList of each vertex is computed. This enables
74
the subtree settings to be made with a single pass simultaneously
75
through the fwdArcList and sortedDFSChildList. See the implementation
76
of CreateDFSTreeEmbedding for details.
77
*/
78
typedef struct
79
{
80
int pathConnector, subtree;
81
} K4Search_GraphNode;
82
83
typedef K4Search_GraphNode * K4Search_GraphNodeP;
84
85
/* Additional equipment for each vertex
86
87
p2dFwdArcCount:
88
During preprocessing, for each vertex we need to know how many forward arcs
89
there are from the DFS parent of the vertex to the DFS descendants of the
90
vertex. As each forward arc is embedded, we decrement this count. When this
91
count reaches zero, we remove the vertex from the sortedDFSChildList of its
92
parent.
93
94
sortedDFSChildList:
95
During preprocessing, we need a list of the DFS children for each vertex,
96
sorted by their DFS numbers. The core planarity/outerplanarity algorithm
97
calculates a separatedDFSChildList that is sorted by the children's Lowpoints.
98
During processing, a child is removed from the sortedDFSChildList of its
99
parent when the p2dFwdArcCount of the child reaches zero. Thus, this list
100
indicates which subtree children of a vertex still contain unresolved
101
pertinence (unembedded forward arcs). The main search for K4 homeomorphs
102
uses this list to efficiently determine the portion of the graph in which
103
to either find a K4 or to perform reductions than enable more forward arcs
104
to be embedded.
105
*/
106
typedef struct
107
{
108
int p2dFwdArcCount, sortedDFSChildList;
109
} K4Search_VertexRec;
110
111
typedef K4Search_VertexRec * K4Search_VertexRecP;
112
113
114
typedef struct
115
{
116
// Helps distinguish initialize from re-initialize
117
int initialized;
118
119
// The graph that this context augments
120
graphP theGraph;
121
122
// Additional graph-level equipment
123
listCollectionP sortedDFSChildLists;
124
125
// Parallel array for additional graph node level equipment
126
K4Search_GraphNodeP G;
127
128
// Parallel array for additional vertex level equipment
129
K4Search_VertexRecP V;
130
131
// Overloaded function pointers
132
graphFunctionTable functions;
133
134
} K4SearchContext;
135
136
#ifdef __cplusplus
137
}
138
#endif
139
140
#endif
141
142