Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/graphs/planarity/graphDrawPlanar.private.h
4091 views
1
#ifndef GRAPH_DRAWPLANAR_PRIVATE_H
2
#define GRAPH_DRAWPLANAR_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
pos, start, end: used to store a visibility representation, or
57
horvert diagram of a planar graph.
58
For vertices, vertical position, horizontal range
59
For edges, horizontal position, vertical range
60
*/
61
typedef struct
62
{
63
int pos, start, end;
64
} DrawPlanar_GraphNode;
65
66
typedef DrawPlanar_GraphNode * DrawPlanar_GraphNodeP;
67
68
// Additional equipment for each vertex
69
/*
70
drawingFlag, ancestor, ancestorChild: used to collect information needed
71
to help 'draw' a visibility representation. During planar
72
embedding, a vertex is determined to be between its DFS parent and
73
a given ancestor (the vertex being processed) or beyond the parent
74
relative to the ancestor. In post processing, the relative
75
orientation of the parent and ancestor are determined,
76
then the notion of between/beyond resolves to above/below or
77
below/above depending on whether the ancestor is above or below,
78
respectively, the parent. The ancestorChild are used to help r
79
esolve this latter question.
80
tie[2] stores information along the external face during embedding
81
that is pertinent to helping break ties in the decisions about
82
vertical vertex positioning. When vertices are first merged
83
together into a bicomp, we cannot always decide right away which
84
vertices will be above or below others. But as we traverse the
85
external face removing inactive vertices, these positional ties
86
can be resolved.
87
*/
88
typedef struct
89
{
90
int drawingFlag, ancestor, ancestorChild;
91
int tie[2];
92
} DrawPlanar_VertexRec;
93
94
typedef DrawPlanar_VertexRec * DrawPlanar_VertexRecP;
95
96
#define DRAWINGFLAG_BEYOND 0
97
#define DRAWINGFLAG_TIE 1
98
#define DRAWINGFLAG_BETWEEN 2
99
#define DRAWINGFLAG_BELOW 3
100
#define DRAWINGFLAG_ABOVE 4
101
102
typedef struct
103
{
104
// Helps distinguish initialize from re-initialize
105
int initialized;
106
107
// The graph that this context augments
108
graphP theGraph;
109
110
// Parallel array for additional graph node level equipment
111
DrawPlanar_GraphNodeP G;
112
113
// Parallel array for additional vertex level equipment
114
DrawPlanar_VertexRecP V;
115
116
// Overloaded function pointers
117
graphFunctionTable functions;
118
119
} DrawPlanarContext;
120
121
#ifdef __cplusplus
122
}
123
#endif
124
125
#endif
126
127
128