Debian Codegraph @

Kernel/dlDag.h

raw symbols SCIP
1 /* This file is part of the FaCT++ DL reasoner
2 Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester
3 Copyright (C) 2015-2017 Dmitry Tsarkov
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #ifndef DLDAG_H
21 #define DLDAG_Hcxx . . $ `Kernel/dlDag.h:21:9`!
22
23 #include <vector>
24 #include <cstring> // strlen
25
26 #include "globaldef.h"cxx . . $ `<file>/Kernel/globaldef.h`/ // for statistic printed
27 #include "fpp_assert.h"cxx . . $ `<file>/Kernel/fpp_assert.h`/
28 #include "dlVertex.h"cxx . . $ `<file>/Kernel/dlVertex.h`/
29 #include "dlVHash.h"cxx . . $ `<file>/Kernel/dlVHash.h`/
30 #include "ifOptions.h"cxx . . $ `<file>/Kernel/ifOptions.h`/
31 #include "tRole.h"cxx . . $ `<file>/Kernel/tRole.h`/
32 #include "ConceptWithDep.h"cxx . . $ `<file>/Kernel/ConceptWithDep.h`/
33 #include "tNECollection.h"cxx . . $ `<file>/Kernel/tNECollection.h`/
34
35 class RoleMastercxx . . $ RoleMaster#;
36 class TConceptcxx . . $ TConcept#;
37
38 /** DAG of DL Vertices used in FaCT++ reasoner */
39 class DLDagcxx . . $ DLDag#
40 {
41 public: // types
42 typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<DLVertexcxx . . $ DLVertex#*> HeapTypecxx . . $ DLDag#HeapType#;
43 typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<BipolarPointercxx . . $ BipolarPointer#> StatVectorcxx . . $ DLDag#StatVector#;
44 /// typedef for the hash-table
45 typedef dlVHashTablecxx . . $ dlVHashTable# HashTablecxx . . $ DLDag#HashTable#;
46
47 protected: // members
48 /// body of DAG
49 HeapTypecxx . . $ DLDag#HeapType# Heapcxx . . $ DLDag#Heap.;
50 /// all the AND nodes (needs to recompute)
51 StatVectorcxx . . $ DLDag#StatVector# listAndscxx . . $ DLDag#listAnds.;
52 /// hash-table for vertices (and, all, LE) fast search
53 HashTablecxx . . $ DLDag#HashTable# indexAndcxx . . $ DLDag#indexAnd., indexAllcxx . . $ DLDag#indexAll., indexLEcxx . . $ DLDag#indexLE.;
54
55 /// DAG size after the whole ontology is loaded
56 size_tcxx . . $ size_t# finalDagSizecxx . . $ DLDag#finalDagSize. = 0;
57 /// cache efficiency -- statistic purposes
58 unsigned int nCacheHitscxx . . $ DLDag#nCacheHits. = 0;
59
60 #ifdef RKG_USE_SORTED_REASONINGcxx . . $ `Kernel/globaldef.h:40:9`!
61 /// size of sort array
62 size_tcxx . . $ size_t# sortArraySizecxx . . $ DLDag#sortArraySize. = 0;
63 #endif
64
65 // tunable flags (set by readConfig)
66
67 /// sort strings: option[0] for SAT/cache tests, option[1] for SUB/classify tests
68 const char* orSortSatcxx . . $ DLDag#orSortSat. = nullptr;
69 const char* orSortSubcxx . . $ DLDag#orSortSub. = nullptr;
70 /// sort index (if necessary). Possible values are Size, Depth, Freq
71 unsigned int iSortcxx . . $ DLDag#iSort. = 0;
72 /// whether or not sorting order is ascending
73 bool sortAscendcxx . . $ DLDag#sortAscend. = false;
74 /// prefer non-generating rules in OR orderings
75 bool preferNonGencxx . . $ DLDag#preferNonGen. = false;
76
77 /// flag whether cache should be used
78 bool useDLVCachecxx . . $ DLDag#useDLVCache. = true;
79
80 protected: // methods
81 /// setup flags by given option set
82 void readConfigcxx . . $ DLDag#readConfig(caa43d10477a9290). ( const ifOptionSetcxx . . $ ifOptionSet#* Options );
83 /// check if given string is correct sort ordering representation
84 bool isCorrectOptioncxx . . $ DLDag#isCorrectOption(c5f7da30cbc0f4e9). ( const char* str )
85 {
86 if ( str == nullptr )
87 return false;
88 size_tcxx . . $ size_t# n = strlen(str);
89 if ( n < 1 || n > 3 )
90 return false;
91 char Method = str[0],
92 Order = n >= 2 ? str[1] : 'a',
93 NGPref = n == 3 ? str[2] : 'p';
94 return ( Method == 'S' || Method == 'D' || Method == 'F' ||
95 Method == 'B' || Method == 'G' || Method == '0' )
96 && ( Order == 'a' || Order == 'd' ) && ( NGPref == 'p' || NGPref == 'n' );
97 }
98 /// gather vertex statistics (no freq)
99 void computeVertexStatcxx . . $ DLDag#computeVertexStat(d4f767463ce0a6b3). ( BipolarPointercxx . . $ BipolarPointer# p );
100 /// helper for the recursion
101 void computeVertexStatcxx . . $ DLDag#computeVertexStat(918ebd27a9ddbad3). ( BipolarPointercxx . . $ BipolarPointer# p, bool pos ) { computeVertexStatcxx . . $ DLDag#computeVertexStat(d4f767463ce0a6b3). ( createBiPointercxx . . $ createBiPointer(d455ce14f374a3ab). ( p, pos ) ); }
102 /// update vertex statistics (no freq) wrt calculated values of children
103 void updateVertexStatcxx . . $ DLDag#updateVertexStat(d4f767463ce0a6b3). ( BipolarPointercxx . . $ BipolarPointer# p );
104 /// helper for the recursion
105 void updateVertexStatcxx . . $ DLDag#updateVertexStat(ab0e588a24d66dd3). ( DLVertexcxx . . $ DLVertex#& v, BipolarPointercxx . . $ BipolarPointer# p, bool pos )
106 {
107 const DLVertexcxx . . $ DLVertex#& w = (*this)[cxx . . $ DLDag#`operator[]`(e265d70853dfed20).p];
108 bool posW = pos == isPositivecxx . . $ isPositive(83c267b20bac841a).(p);
109
110 // update in-cycle information
111 if ( w.isInCyclecxx . . $ DLVertexTagDFS#isInCycle(962fae8be55e1d9).(posW) )
112 v.setInCyclecxx . . $ DLVertexTagDFS#setInCycle(b45ddcbc8423892c).(pos);
113
114 v.updateStatValuescxx . . $ DLVertexStatistic#updateStatValues(7baf84d5bb3c1273). ( w, posW, pos );
115 }
116 /// gather vertex freq statistics
117 void computeVertexFreqcxx . . $ DLDag#computeVertexFreq(d4f767463ce0a6b3). ( BipolarPointercxx . . $ BipolarPointer# p );
118 /// helper for the recursion
119 void computeVertexFreqcxx . . $ DLDag#computeVertexFreq(918ebd27a9ddbad3). ( BipolarPointercxx . . $ BipolarPointer# p, bool pos ) { computeVertexFreqcxx . . $ DLDag#computeVertexFreq(d4f767463ce0a6b3). ( createBiPointercxx . . $ createBiPointer(d455ce14f374a3ab). ( p, pos ) ); }
120 /// change order of ADD elements wrt statistic
121 void Recomputecxx . . $ DLDag#Recompute(49f6e7a06ebc5aa8). ( void )
122 {
123 for ( StatVectorcxx . . $ DLDag#StatVector#::const_iteratorcxx . . $ std/vector#const_iterator# p = listAndscxx . . $ DLDag#listAnds..begincxx . . $ std/vector#begin(33b10a496a38335b).(), p_end = listAndscxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0)..endcxx . . $ std/vector#end(33b10a496a38335b).(); p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p )
124 (*this)[cxx . . $ DLDag#`operator[]`(e265d70853dfed20).*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p].sortEntrycxx . . $ DLVertex#sortEntry(dd585ec903520274).(*this);
125 }
126 /// set OR sort flags based on given option string; Recompute if necessary
127 void setOrderOptionscxx . . $ DLDag#setOrderOptions(85c52e162fed56f9). ( const char* opt );
128 /// clear all DFS info from elements of DAG
129 void clearDFScxx . . $ DLDag#clearDFS(49f6e7a06ebc5aa8). ( void )
130 {
131 for ( size_tcxx . . $ size_t# i = Heapcxx . . $ DLDag#Heap..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).()-1; i > 0; --i )
132 Heapcxx . . $ DLDag#Heap.[cxx . . $ std/vector#`operator[]`(428bb168810b9e52).i]->clearDFScxx . . $ DLVertexTagDFS#clearDFS(49f6e7a06ebc5aa8).();
133 }
134
135 /// get index corresponding to DLVertex's tag
136 const HashTablecxx . . $ DLDag#HashTable#& getIndexcxx . . $ DLDag#getIndex(a5e3be27243c6236). ( DagTagcxx . . $ DagTag# tag ) const
137 {
138 switch(tag)
139 {
140 case dtAndcxx . . $ dtAnd.: return indexAndcxx . . $ DLDag#indexAnd.;
141 case dtIrrcxx . . $ dtIrr.:
142 case dtForallcxx . . $ dtForall.: return indexAllcxx . . $ DLDag#indexAll.;
143 case dtLEcxx . . $ dtLE.: return indexLEcxx . . $ DLDag#indexLE.;
144 default: fpp_unreachablecxx . . $ EFPPAssertion#(); // no such index
145 }
146 }
147 /// update index corresponding to DLVertex's tag
148 void updateIndexcxx . . $ DLDag#updateIndex(1b450d680d29287e). ( DagTagcxx . . $ DagTag# tag, BipolarPointercxx . . $ BipolarPointer# value )
149 {
150 switch(tag)
151 {
152 case dtAndcxx . . $ dtAnd.: indexAndcxx . . $ DLDag#indexAnd..addElementcxx . . $ dlVHashTable#addElement(d4f767463ce0a6b3).(value); listAndscxx . . $ DLDag#listAnds..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(value); break;
153 case dtIrrcxx . . $ dtIrr.:
154 case dtForallcxx . . $ dtForall.: indexAllcxx . . $ DLDag#indexAll..addElementcxx . . $ dlVHashTable#addElement(d4f767463ce0a6b3).(value); break;
155 case dtLEcxx . . $ dtLE.: indexLEcxx . . $ DLDag#indexLE..addElementcxx . . $ dlVHashTable#addElement(d4f767463ce0a6b3).(value); break;
156 default: break; // nothing to do
157 }
158 }
159
160 #ifdef RKG_USE_SORTED_REASONINGcxx . . $ `Kernel/globaldef.h:40:9`!
161 // internal sort interface
162
163 /// merge sorts for a given role
164 void mergeSortscxx . . $ DLDag#mergeSorts(3d6e099a537f0595). ( TRolecxx . . $ TRole#* R );
165 /// merge sorts for a given vertex
166 void mergeSortscxx . . $ DLDag#mergeSorts(fc1f73a461d00dd2). ( DLVertexcxx . . $ DLVertex#& v );
167 #endif
168
169 #ifdef RKG_PRINT_DAG_USAGE
170 /// print usage of DAG
171 void PrintDAGUsage ( std::ostream& o ) const;
172 #endif
173
174 public: // interface
175 /// the only c'tor
176 explicit DLDagcxx . . $ DLDag#DLDag(caa43d10477a9290). ( const ifOptionSetcxx . . $ ifOptionSet#* Options );
177 /// no copy c'tor
178 DLDagcxx . . $ DLDag#DLDag(dd585ec903520274). ( const DLDagcxx . . $ DLDag#& ) = delete;
179 /// no assignment
180 DLDagcxx . . $ DLDag#& operatorcxx . . $ DLDag#`operator=`(779998f96cdf796b).= ( const DLDagcxx . . $ DLDag#& ) = delete;
181 /// d'tor
182 ~cxx . . $ DLDag#`~DLDag`(49f6e7a06ebc5aa8).DLDagcxx . . $ DLDag#();
183
184 // construction methods
185
186 /// get index of given vertex; include vertex to DAG if necessary
187 BipolarPointercxx . . $ BipolarPointer# addcxx . . $ DLDag#add(b86a49c684080b5d). ( DLVertexcxx . . $ DLVertex#* v );
188 /// add vertex to the end of DAG and calculate it's statistic if necessary
189 BipolarPointercxx . . $ BipolarPointer# directAddcxx . . $ DLDag#directAdd(b86a49c684080b5d). ( DLVertexcxx . . $ DLVertex#* v )
190 {
191 BipolarPointercxx . . $ BipolarPointer# toReturn = BipolarPointercxx . . $ BipolarPointer#(Heapcxx . . $ DLDag#Heap..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).());
192 Heapcxx . . $ DLDag#Heap..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(v);
193 // return an index of just added entry
194 return toReturn;
195 }
196 /// add vertex to the end of DAG and calculate it's statistic if necessary; put it into cache
197 BipolarPointercxx . . $ BipolarPointer# directAddAndCachecxx . . $ DLDag#directAddAndCache(b86a49c684080b5d). ( DLVertexcxx . . $ DLVertex#* v )
198 {
199 BipolarPointercxx . . $ BipolarPointer# ret = directAddcxx . . $ DLDag#directAdd(b86a49c684080b5d).(v);
200 if ( useDLVCachecxx . . $ DLDag#useDLVCache. )
201 updateIndexcxx . . $ DLDag#updateIndex(1b450d680d29287e). ( v->Typecxx . . $ DLVertexTagDFS#Type(d9c59f5f195b46b8).(), ret );
202 return ret;
203 }
204 /// check if given index points to the last DAG entry
205 bool isLastcxx . . $ DLDag#isLast(4a668f6de69bf818). ( BipolarPointercxx . . $ BipolarPointer# p ) const { return (getValuecxx . . $ getValue(46cc46841198e427).(p) == Heapcxx . . $ DLDag#Heap..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).()-1); }
206
207 // access methods
208
209 /// whether to use cache for nodes
210 void setExpressionCachecxx . . $ DLDag#setExpressionCache(b45ddcbc8423892c). ( bool val ) { useDLVCachecxx . . $ DLDag#useDLVCache. = val; }
211 /// return true if p1 is less than p2 using chosen sort order
212 bool lesscxx . . $ DLDag#less(88e30549ca55c866). ( BipolarPointercxx . . $ BipolarPointer# p1, BipolarPointercxx . . $ BipolarPointer# p2 ) const;
213
214 /// access by index (non-const version)
215 DLVertexcxx . . $ DLVertex#& operatorcxx . . $ DLDag#`operator[]`(e265d70853dfed20). [] ( BipolarPointercxx . . $ BipolarPointer# i )
216 {
217 # ifdef ENABLE_CHECKING
218 fpp_assert ( isValid(i) );
219 fpp_assert ( getValue(i) < size() );
220 # endif
221 return *Heapcxx . . $ DLDag#Heap.[cxx . . $ std/vector#`operator[]`(428bb168810b9e52).getValuecxx . . $ getValue(46cc46841198e427).(i)];
222 }
223 /// RW access by index in complex concept
224 DLVertexcxx . . $ DLVertex#& operatorcxx . . $ DLDag#`operator[]`(b4043884e5934906). [] ( const ConceptWDepcxx . . $ ConceptWDep#& cwd ) { return (*this)[cxx . . $ DLDag#`operator[]`(e265d70853dfed20).cwd.bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).()]; }
225 /// access by index (const version)
226 const DLVertexcxx . . $ DLVertex#& operatorcxx . . $ DLDag#`operator[]`(5fe3b8e96045ba2c). [] ( BipolarPointercxx . . $ BipolarPointer# i ) const
227 {
228 # ifdef ENABLE_CHECKING
229 fpp_assert ( isValid(i) );
230 fpp_assert ( getValue(i) < size() );
231 # endif
232 return *Heapcxx . . $ DLDag#Heap.[cxx . . $ std/vector#`operator[]`(b61e45a10b63f40a).getValuecxx . . $ getValue(46cc46841198e427).(i)];
233 }
234 /// RO access by index in complex concept
235 const DLVertexcxx . . $ DLVertex#& operatorcxx . . $ DLDag#`operator[]`(674db0146e4e3588). [] ( const ConceptWDepcxx . . $ ConceptWDep#& cwd ) const { return (*this)[cxx . . $ DLDag#`operator[]`(5fe3b8e96045ba2c).cwd.bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).()]; }
236 /// replace existing vertex at index I with a vertex V
237 void replaceVertexcxx . . $ DLDag#replaceVertex(14070e212d00ba12). ( BipolarPointercxx . . $ BipolarPointer# i, DLVertexcxx . . $ DLVertex#* v, TNamedEntrycxx . . $ TNamedEntry#* C )
238 {
239 delete Heapcxx . . $ DLDag#Heap.[cxx . . $ std/vector#`operator[]`(428bb168810b9e52).getValuecxx . . $ getValue(46cc46841198e427).(i)];
240 Heapcxx . . $ DLDag#Heap.[cxx . . $ std/vector#`operator[]`(428bb168810b9e52).getValuecxx . . $ getValue(46cc46841198e427).(i)] = v;
241 v->setConceptcxx . . $ DLVertex#setConcept(69d9f70ea506b4a4).(C);
242 }
243
244 /// get size of DAG
245 size_tcxx . . $ size_t# sizecxx . . $ DLDag#size(fe4d2d262d4164a8). ( void ) const { return Heapcxx . . $ DLDag#Heap..sizecxx . . $ std/vector#size(fe4d2d262d4164a8). (); }
246 /// get approximation of the size after query is added
247 size_tcxx . . $ size_t# maxSizecxx . . $ DLDag#maxSize(fe4d2d262d4164a8). ( void ) const { return sizecxx . . $ DLDag#size(fe4d2d262d4164a8).() + ( sizecxx . . $ DLDag#size(fe4d2d262d4164a8).() < 220 ? 10 : sizecxx . . $ DLDag#size(fe4d2d262d4164a8).()/20 ); }
248 /// set the final DAG size
249 void setFinalSizecxx . . $ DLDag#setFinalSize(49f6e7a06ebc5aa8). ( void ) { finalDagSizecxx . . $ DLDag#finalDagSize. = sizecxx . . $ DLDag#size(fe4d2d262d4164a8).(); setExpressionCachecxx . . $ DLDag#setExpressionCache(b45ddcbc8423892c).(false); }
250 /// resize DAG to its original size (to clear intermediate query)
251 void removeQuerycxx . . $ DLDag#removeQuery(49f6e7a06ebc5aa8). ( void );
252
253 // option interface
254
255 /// set defaults of OR orderings
256 void setOrderDefaultscxx . . $ DLDag#setOrderDefaults(2fa786934fe80e24). ( const char* defSat, const char* defSub );
257 /// use SUB options to OR ordering
258 void setSubOrdercxx . . $ DLDag#setSubOrder(49f6e7a06ebc5aa8). ( void ) { setOrderOptionscxx . . $ DLDag#setOrderOptions(85c52e162fed56f9).(orSortSubcxx . . $ DLDag#orSortSub.); }
259 /// use SAT options to OR ordering;
260 void setSatOrdercxx . . $ DLDag#setSatOrder(49f6e7a06ebc5aa8). ( void ) { setOrderOptionscxx . . $ DLDag#setOrderOptions(85c52e162fed56f9).(orSortSatcxx . . $ DLDag#orSortSat.); }
261 /// gather statistics necessary for the OR ordering
262 void gatherStatisticcxx . . $ DLDag#gatherStatistic(49f6e7a06ebc5aa8). ( void );
263
264 // cache interface
265
266 /// get cache for given BiPointer (may return NULL if no cache defined)
267 const modelCacheInterfacecxx . . $ modelCacheInterface#* getCachecxx . . $ DLDag#getCache(a400da756ae1652b). ( BipolarPointercxx . . $ BipolarPointer# p ) const
268 { return operator[](p).getCachecxx . . $ DLVertexCache#getCache(b56d42e3b093d25c).(isPositivecxx . . $ isPositive(83c267b20bac841a).(p)); }
269 /// set cache for given BiPointer; @return given cache
270 void setCachecxx . . $ DLDag#setCache(5d5e965ff81adf26). ( BipolarPointercxx . . $ BipolarPointer# p, const modelCacheInterfacecxx . . $ modelCacheInterface#* cache )
271 { operator[](p).setCachecxx . . $ DLVertexCache#setCache(f730227c2b1a60d2). ( isPositivecxx . . $ isPositive(83c267b20bac841a).(p), cache ); }
272
273 // sort interface
274
275 #ifdef RKG_USE_SORTED_REASONINGcxx . . $ `Kernel/globaldef.h:40:9`!
276 /// merge two given DAG entries
277 void mergecxx . . $ DLDag#merge(b399d136bc0b5cf7). ( mergeableLabelcxx . . $ mergeableLabel#& ml, BipolarPointercxx . . $ BipolarPointer# p )
278 {
279 if ( p != bpINVALIDcxx . . $ bpINVALID. && p != bpTOPcxx . . $ bpTOP. && p != bpBOTTOMcxx . . $ bpBOTTOM. )
280 (*this)[cxx . . $ DLDag#`operator[]`(e265d70853dfed20).p].mergecxx . . $ DLVertexSort#merge(e3a03ee78af03ab7).(ml);
281 }
282 /// build the sort system for given TBox
283 void determineSortscxx . . $ DLDag#determineSorts(553262e3595539a7). ( RoleMastercxx . . $ RoleMaster#& ORM, RoleMastercxx . . $ RoleMaster#& DRM );
284 /// update sorts for <a,b>:R construction
285 void updateSortscxx . . $ DLDag#updateSorts(f5f2d1ccf66c503). ( BipolarPointercxx . . $ BipolarPointer# a, TRolecxx . . $ TRole#* R, BipolarPointercxx . . $ BipolarPointer# b )
286 {
287 mergecxx . . $ DLDag#merge(b399d136bc0b5cf7). ( R->getDomainLabelcxx . . $ TRole#getDomainLabel(e1d2169d387f9f72).(), a );
288 mergecxx . . $ DLDag#merge(b399d136bc0b5cf7). ( R->getRangeLabelcxx . . $ TRole#getRangeLabel(e1d2169d387f9f72).(), b );
289 }
290 /// check if two BPs are of the same sort
291 bool haveSameSortcxx . . $ DLDag#haveSameSort(88e30549ca55c866). ( BipolarPointercxx . . $ BipolarPointer# p, BipolarPointercxx . . $ BipolarPointer# q ) const
292 {
293 fpp_assertcxx . . $ EFPPAssertion#EFPPAssertion(85c52e162fed56f9). ( p > 0 && q > 0 ); // sanity check
294
295 // everything has the same label as TOP
296 if ( unlikelycxx . . $ `Kernel/globaldef.h:29:10`!(p == 1 || q == 1) )
297 return true;
298
299 // if some concepts were added to DAG => nothing to say
300 if ( unlikelycxx . . $ getValue(46cc46841198e427).(getValue(p) >= sortArraySize || getValue(q) >= sortArraySize) )
301 return true;
302
303 // check whether two sorts are identical
304 return (*this)[cxx . . $ DLDag#`operator[]`(5fe3b8e96045ba2c).p].getSortcxx . . $ DLVertexSort#getSort(16201f018f613e0c).() ==cxx . . $ mergeableLabel#`operator==`(699a620365433952). (*this)[cxx . . $ DLDag#`operator[]`(5fe3b8e96045ba2c).q].getSortcxx . . $ DLVertexSort#getSort(16201f018f613e0c).();
305 }
306 #else
307 bool haveSameSort ( unsigned int p, unsigned int q ) { return true; }
308 #endif
309
310 // output interface
311
312 /// print DAG size and number of cache hits, together with DAG usage
313 void PrintStatcxx . . $ DLDag#PrintStat(490063bd7e6d8d5d). ( stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& o ) const
314 {
315 o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Heap size = " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). Heapcxx . . $ DLDag#Heap..sizecxx . . $ std/vector#size(fe4d2d262d4164a8). () <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " nodes\n"
316 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "There were " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). nCacheHitscxx . . $ DLDag#nCacheHits. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " cache hits\n";
317 # ifdef RKG_PRINT_DAG_USAGE
318 PrintDAGUsage(o);
319 # endif
320 }
321 /// print the whole DAG
322 void Printcxx . . $ DLDag#Print(490063bd7e6d8d5d). ( stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& o ) const
323 {
324 o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\nDag structure";
325
326 for ( size_tcxx . . $ size_t# i = 1; i < sizecxx . . $ DLDag#size(fe4d2d262d4164a8).(); ++i )
327 {
328 o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n" <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). i <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " ";
329 Heapcxx . . $ DLDag#Heap.[cxx . . $ std/vector#`operator[]`(b61e45a10b63f40a).i]->Printcxx . . $ DLVertex#Print(490063bd7e6d8d5d).(o);
330 }
331
332 o <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
333 }
334 }; // DLDag
335
336 #include "dlVHashImpl.h"cxx . . $ `<file>/Kernel/dlVHashImpl.h`/
337
338 inline BipolarPointercxx . . $ BipolarPointer#
339 DLDagcxx . . $ DLDag# :: addcxx . . $ DLDag#add(b86a49c684080b5d). ( DLVertexcxx . . $ DLVertex#* v )
340 {
341 BipolarPointercxx . . $ BipolarPointer# ret = useDLVCachecxx . . $ DLDag#useDLVCache. ? getIndexcxx . . $ DLDag#getIndex(a5e3be27243c6236).(v->Typecxx . . $ DLVertexTagDFS#Type(d9c59f5f195b46b8).()).locatecxx . . $ dlVHashTable#locate(afc6382ab0cd3b8b).(*v) : bpINVALIDcxx . . $ bpINVALID.;
342
343 if ( !isValidcxx . . $ isValid(83c267b20bac841a).(ret) ) // we fail to find such vertex -- it's new
344 return directAddAndCachecxx . . $ DLDag#directAddAndCache(b86a49c684080b5d).(v);
345
346 // node was found in cache
347 ++nCacheHitscxx . . $ DLDag#nCacheHits.;
348 delete v;
349 return ret;
350 }
351
352 #endif