| 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 | #include "dlCompletionGraph.h"cxx . . $ `<file>/Kernel/dlCompletionGraph.h`/ |
| 21 | |
| 22 | DlCompletionTreeArccxx . . $ DlCompletionTreeArc#* |
| 23 | DlCompletionGraphcxx . . $ DlCompletionGraph# :: createEdgecxx . . $ DlCompletionGraph#createEdge(2369b4bf26f5db64). ( |
| 24 | DlCompletionTreecxx . . $ DlCompletionTree#* from, |
| 25 | DlCompletionTreecxx . . $ DlCompletionTree#* to, |
| 26 | bool isPredEdge, |
| 27 | const TRolecxx . . $ TRole#* roleName, |
| 28 | const DepSetcxx . . $ DepSet#& dep ) |
| 29 | { |
| 30 | // create 2 arcs between FROM and TO |
| 31 | DlCompletionTreeArccxx . . $ DlCompletionTreeArc#* forward = CTEdgeHeapcxx . . $ DlCompletionGraph#CTEdgeHeap..getcxx . . $ DeletelessAllocator#get(155dc7f103cdb9db).(); |
| 32 | forward->initcxx . . $ DlCompletionTreeArc#init(dd061ef82546eda3). ( roleName, dep, to ); |
| 33 | forward->setSuccEdgecxx . . $ DlCompletionTreeArc#setSuccEdge(b45ddcbc8423892c).(!isPredEdge); |
| 34 | DlCompletionTreeArccxx . . $ DlCompletionTreeArc#* backward = CTEdgeHeapcxx . . $ DlCompletionGraph#CTEdgeHeap..getcxx . . $ DeletelessAllocator#get(155dc7f103cdb9db).(); |
| 35 | backward->initcxx . . $ DlCompletionTreeArc#init(dd061ef82546eda3). ( roleName->inversecxx . . $ TRole#inverse(69f26110a94b259f).(), dep, from ); |
| 36 | backward->setSuccEdgecxx . . $ DlCompletionTreeArc#setSuccEdge(b45ddcbc8423892c).(isPredEdge); |
| 37 | // set the reverse link |
| 38 | forward->setReversecxx . . $ DlCompletionTreeArc#setReverse(7cce2cce5bd28a53).(backward); |
| 39 | |
| 40 | // connect them to nodes |
| 41 | saveNodecxx . . $ DlCompletionGraph#saveNode(aa3cbc006cb08887). ( from, branchingLevelcxx . . $ DlCompletionGraph#branchingLevel. ); |
| 42 | saveNodecxx . . $ DlCompletionGraph#saveNode(aa3cbc006cb08887). ( to, branchingLevelcxx . . $ DlCompletionGraph#branchingLevel. ); |
| 43 | // add the edges as corresponding neighbours |
| 44 | from->addNeighbourcxx . . $ DlCompletionTree#addNeighbour(7cce2cce5bd28a53).(forward); |
| 45 | to->addNeighbourcxx . . $ DlCompletionTree#addNeighbour(7cce2cce5bd28a53).(backward); |
| 46 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llGTAcxx . . $ llGTA.) ) |
| 47 | { |
| 48 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " ce("; |
| 49 | if ( isPredEdge ) |
| 50 | LLcxx . . $ LL. <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). to->getIdcxx . . $ DlCompletionTree#getId(ddd8539a2fcdd4ce).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "<-" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). from->getIdcxx . . $ DlCompletionTree#getId(ddd8539a2fcdd4ce).(); |
| 51 | else |
| 52 | LLcxx . . $ LL. <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). from->getIdcxx . . $ DlCompletionTree#getId(ddd8539a2fcdd4ce).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "->" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). to->getIdcxx . . $ DlCompletionTree#getId(ddd8539a2fcdd4ce).(); |
| 53 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "," <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). roleName->getNamecxx . . $ TNamedEntry#getName(a9f41ea0e82d88cf).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ")"; |
| 54 | } |
| 55 | |
| 56 | return forward; |
| 57 | } |
| 58 | |
| 59 | /// replace the EDGE (that comes from old node to X) with a new one, that comes from NODE to X |
| 60 | DlCompletionTreeArccxx . . $ DlCompletionTreeArc#* |
| 61 | DlCompletionGraphcxx . . $ DlCompletionGraph# :: moveEdgecxx . . $ DlCompletionGraph#moveEdge(58152daba81a1ee3). ( DlCompletionTreecxx . . $ DlCompletionTree#* node, DlCompletionTreeArccxx . . $ DlCompletionTreeArc#* edge, |
| 62 | bool isPredEdge, const DepSetcxx . . $ DepSet#& dep ) |
| 63 | { |
| 64 | // skip already purged edges |
| 65 | if ( edge->isIBlockedcxx . . $ DlCompletionTreeArc#isIBlocked(50ce9a9e25b4a850).()) |
| 66 | return nullptr; |
| 67 | |
| 68 | // skip edges not leading to nominal nodes |
| 69 | if ( !isPredEdge && !edge->getArcEndcxx . . $ DlCompletionTreeArc#getArcEnd(1b0634bb62d2788b).()->isNominalNodecxx . . $ DlCompletionTree#isNominalNode(50ce9a9e25b4a850).() ) |
| 70 | return nullptr; |
| 71 | |
| 72 | const TRolecxx . . $ TRole#* R = edge->getRolecxx . . $ DlCompletionTreeArc#getRole(69f26110a94b259f).(); |
| 73 | |
| 74 | // we shall copy reflexive edges in a specific way |
| 75 | if ( edge->isReflexiveEdgecxx . . $ DlCompletionTreeArc#isReflexiveEdge(50ce9a9e25b4a850).() ) |
| 76 | return createLoopcxx . . $ DlCompletionGraph#createLoop(882ef0e58548cfd4). ( node, R, dep ); |
| 77 | |
| 78 | DlCompletionTreecxx . . $ DlCompletionTree#* to = edge->getArcEndcxx . . $ DlCompletionTreeArc#getArcEnd(1b0634bb62d2788b).(); |
| 79 | |
| 80 | // invalidate old edge |
| 81 | invalidateEdgecxx . . $ DlCompletionGraph#invalidateEdge(7cce2cce5bd28a53).(edge); |
| 82 | |
| 83 | // try to find for NODE->TO (TO->NODE) whether we |
| 84 | // have TO->NODE (NODE->TO) edge already |
| 85 | for ( DlCompletionTreecxx . . $ DlCompletionTree#::const_edge_iteratorcxx . . $ DlCompletionTree#const_edge_iterator# p = nodecxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0).->begincxx . . $ DlCompletionTree#begin(de7d1c517ae77062).(), p_end = nodecxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0).->endcxx . . $ DlCompletionTree#end(de7d1c517ae77062).(); p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 86 | if ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->getArcEndcxx . . $ DlCompletionTreeArc#getArcEnd(1b0634bb62d2788b).() == to && (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->isPredEdgecxx . . $ DlCompletionTreeArc#isPredEdge(50ce9a9e25b4a850).() != isPredEdge ) |
| 87 | return addRoleLabelcxx . . $ DlCompletionGraph#addRoleLabel(2369b4bf26f5db64). ( node, to, !isPredEdge, R, dep ); |
| 88 | |
| 89 | return addRoleLabelcxx . . $ DlCompletionGraph#addRoleLabel(2369b4bf26f5db64). ( node, to, isPredEdge, R, dep ); |
| 90 | } |
| 91 | |
| 92 | // merge labels; see SHOIN paper for detailed description |
| 93 | void DlCompletionGraphcxx . . $ DlCompletionGraph# :: Mergecxx . . $ DlCompletionGraph#Merge(e2735435d305419c). ( DlCompletionTreecxx . . $ DlCompletionTree#* from, DlCompletionTreecxx . . $ DlCompletionTree#* to, |
| 94 | const DepSetcxx . . $ DepSet#& dep, |
| 95 | std::vectorcxx . . $ std/vector#<DlCompletionTreeArccxx . . $ DlCompletionTreeArc#*>& edges ) |
| 96 | { |
| 97 | edges.clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).(); |
| 98 | |
| 99 | // 1. For all x: x->FROM make x->TO |
| 100 | // FIXME!! no optimisations (in case there exists an edge TO->x labelled with R-) |
| 101 | // 2. For all nominal x: FROM->x make TO->x |
| 102 | // FIXME!! no optimisations (in case there exists an edge x->TO labelled with R-) |
| 103 | for ( DlCompletionTreecxx . . $ DlCompletionTree#::const_edge_iteratorcxx . . $ DlCompletionTree#const_edge_iterator# p = fromcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0).->begincxx . . $ DlCompletionTree#begin(de7d1c517ae77062).(), p_end = fromcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0).->endcxx . . $ DlCompletionTree#end(de7d1c517ae77062).(); p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 104 | { |
| 105 | if ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->isPredEdgecxx . . $ DlCompletionTreeArc#isPredEdge(50ce9a9e25b4a850).() || (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->getArcEndcxx . . $ DlCompletionTreeArc#getArcEnd(1b0634bb62d2788b).()->isNominalNodecxx . . $ DlCompletionTree#isNominalNode(50ce9a9e25b4a850).() ) |
| 106 | { |
| 107 | DlCompletionTreeArccxx . . $ DlCompletionTreeArc#* temp = moveEdgecxx . . $ DlCompletionGraph#moveEdge(58152daba81a1ee3). ( to, *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p, (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->isPredEdgecxx . . $ DlCompletionTreeArc#isPredEdge(50ce9a9e25b4a850).(), dep ); |
| 108 | if ( temp != nullptr ) |
| 109 | edges.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(temp); |
| 110 | } |
| 111 | if ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->isSuccEdgecxx . . $ DlCompletionTreeArc#isSuccEdge(50ce9a9e25b4a850).() ) |
| 112 | purgeEdgecxx . . $ DlCompletionGraph#purgeEdge(922b6183ddf1e042). ( *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p, to, dep ); |
| 113 | } |
| 114 | |
| 115 | // 4. For all x: FROM \neq x, add TO \neq x |
| 116 | updateIRcxx . . $ DlCompletionGraph#updateIR(4c11a3ac995a241a). ( to, from, dep ); |
| 117 | |
| 118 | // 5. Purge FROM |
| 119 | purgeNodecxx . . $ DlCompletionGraph#purgeNode(4c11a3ac995a241a). ( from, to, dep ); |
| 120 | } |
| 121 | |
| 122 | void |
| 123 | DlCompletionGraphcxx . . $ DlCompletionGraph# :: purgeNodecxx . . $ DlCompletionGraph#purgeNode(4c11a3ac995a241a). ( DlCompletionTreecxx . . $ DlCompletionTree#* p, const DlCompletionTreecxx . . $ DlCompletionTree#* root, const DepSetcxx . . $ DepSet#& dep ) |
| 124 | { |
| 125 | if ( p->isPBlockedcxx . . $ DlCompletionTree#isPBlocked(50ce9a9e25b4a850).() ) |
| 126 | return; |
| 127 | |
| 128 | saveRareCondcxx . . $ DlCompletionGraph#saveRareCond(1cbbef85a2ba1293). ( p->setPBlockedcxx . . $ DlCompletionTree#setPBlocked(7616d0d20370b11b). ( root, dep ) ); |
| 129 | |
| 130 | // update successors |
| 131 | for ( DlCompletionTreecxx . . $ DlCompletionTree#::const_edge_iteratorcxx . . $ DlCompletionTree#const_edge_iterator# q = pcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0).->begincxx . . $ DlCompletionTree#begin(de7d1c517ae77062).(); q !=cxx . . $ __gnu_cxx/`operator!=`(9b2ee563b24e7156). p->endcxx . . $ DlCompletionTree#end(de7d1c517ae77062).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).q ) |
| 132 | if ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q)->isSuccEdgecxx . . $ DlCompletionTreeArc#isSuccEdge(50ce9a9e25b4a850).() && !(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q)->isIBlockedcxx . . $ DlCompletionTreeArc#isIBlocked(50ce9a9e25b4a850).() ) |
| 133 | purgeEdgecxx . . $ DlCompletionGraph#purgeEdge(922b6183ddf1e042). ( *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q, root, dep ); |
| 134 | } |
| 135 | |
| 136 | /// purge edge E with given ROOT and DEP-set |
| 137 | void |
| 138 | DlCompletionGraphcxx . . $ DlCompletionGraph# :: purgeEdgecxx . . $ DlCompletionGraph#purgeEdge(922b6183ddf1e042). ( DlCompletionTreeArccxx . . $ DlCompletionTreeArc#* e, const DlCompletionTreecxx . . $ DlCompletionTree#* root, const DepSetcxx . . $ DepSet#& dep ) |
| 139 | { |
| 140 | invalidateEdgecxx . . $ DlCompletionGraph#invalidateEdge(7cce2cce5bd28a53).(e); // invalidate given link |
| 141 | if ( e->getArcEndcxx . . $ DlCompletionTreeArc#getArcEnd(1b0634bb62d2788b).()->isBlockableNodecxx . . $ DlCompletionTree#isBlockableNode(50ce9a9e25b4a850).() ) |
| 142 | purgeNodecxx . . $ DlCompletionGraph#purgeNode(4c11a3ac995a241a). ( e->getArcEndcxx . . $ DlCompletionTreeArc#getArcEnd(1b0634bb62d2788b).(), root, dep ); // purge blockable successor |
| 143 | } |
| 144 | |
| 145 | // save/restore |
| 146 | |
| 147 | void DlCompletionGraphcxx . . $ DlCompletionGraph# :: savecxx . . $ DlCompletionGraph#save(49f6e7a06ebc5aa8). ( void ) |
| 148 | { |
| 149 | SaveStatecxx . . $ DlCompletionGraph#SaveState#* s = Stackcxx . . $ DlCompletionGraph#Stack..pushcxx . . $ TSaveStack#push(155dc7f103cdb9db).(); |
| 150 | s->nNodescxx . . $ DlCompletionGraph#SaveState#nNodes. = endUsedcxx . . $ DlCompletionGraph#endUsed.; |
| 151 | s->sNodescxx . . $ DlCompletionGraph#SaveState#sNodes. = SavedNodescxx . . $ DlCompletionGraph#SavedNodes..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); |
| 152 | s->nEdgescxx . . $ DlCompletionGraph#SaveState#nEdges. = CTEdgeHeapcxx . . $ DlCompletionGraph#CTEdgeHeap..sizecxx . . $ growingArrayP#size(fe4d2d262d4164a8).(); |
| 153 | RareStackcxx . . $ DlCompletionGraph#RareStack..incLevelcxx . . $ TRareSaveStack#incLevel(49f6e7a06ebc5aa8).(); |
| 154 | ++branchingLevelcxx . . $ DlCompletionGraph#branchingLevel.; |
| 155 | } |
| 156 | |
| 157 | void DlCompletionGraphcxx . . $ DlCompletionGraph# :: restorecxx . . $ DlCompletionGraph#restore(cb2f890c2fdad230). ( unsigned int level ) |
| 158 | { |
| 159 | fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( level > 0 ); |
| 160 | branchingLevelcxx . . $ DlCompletionGraph#branchingLevel. = level; |
| 161 | RareStackcxx . . $ DlCompletionGraph#RareStack..restorecxx . . $ TRareSaveStack#restore(cb2f890c2fdad230).(level); |
| 162 | SaveStatecxx . . $ DlCompletionGraph#SaveState#* s = Stackcxx . . $ DlCompletionGraph#Stack..popcxx . . $ TSaveStack#pop(18e8862a30c27574).(level); |
| 163 | endUsedcxx . . $ DlCompletionGraph#endUsed. = s->nNodescxx . . $ DlCompletionGraph#SaveState#nNodes.; |
| 164 | size_tcxx . . $ std/size_t# nSaved = s->sNodescxx . . $ DlCompletionGraph#SaveState#sNodes.; |
| 165 | iteratorcxx . . $ DlCompletionGraph#iterator# p = SavedNodescxx . . $ DlCompletionGraph#SavedNodes..begincxx . . $ std/vector#begin(33b10a496a38335b).()+cxx . . $ __gnu_cxx/__normal_iterator#operator+(d0cb2d2ebd313f38).(long)nSaved, p_end = SavedNodescxx . . $ DlCompletionGraph#SavedNodes..endcxx . . $ std/vector#end(33b10a496a38335b).(); |
| 166 | if ( endUsedcxx . . $ DlCompletionGraph#endUsed. < size_tcxx . . $ std/size_t#(p_end-cxx . . $ __gnu_cxx/operator-(a40477c209547c13).p) ) // it's cheaper to restore all nodes |
| 167 | for ( p =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(e70d8a60e026d72c). begincxx . . $ DlCompletionGraph#begin(279e9fe68f310cbf).(), p_end =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(e70d8a60e026d72c). endcxx . . $ DlCompletionGraph#end(279e9fe68f310cbf).(); p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 168 | restoreNodecxx . . $ DlCompletionGraph#restoreNode(aa3cbc006cb08887). ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p), level ); |
| 169 | else |
| 170 | for ( ; p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 171 | if ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->getIdcxx . . $ DlCompletionTree#getId(ddd8539a2fcdd4ce).() < endUsedcxx . . $ DlCompletionGraph#endUsed. ) // don't restore nodes that are dead anyway |
| 172 | restoreNodecxx . . $ DlCompletionGraph#restoreNode(aa3cbc006cb08887). ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p), level ); |
| 173 | SavedNodescxx . . $ DlCompletionGraph#SavedNodes..resizecxx . . $ std/vector#resize(2c44cd906ae4e829).(nSaved); |
| 174 | CTEdgeHeapcxx . . $ DlCompletionGraph#CTEdgeHeap..resizecxx . . $ growingArrayP#resize(2c44cd906ae4e829).(s->nEdgescxx . . $ DlCompletionGraph#SaveState#nEdges.); |
| 175 | } |
| 176 | |
| 177 | // printing CGraph |
| 178 | |
| 179 | void DlCompletionGraphcxx . . $ DlCompletionGraph# :: Printcxx . . $ DlCompletionGraph#Print(f7f45734e6842120). ( std::ostreamcxx . . $ std/ostream#& o ) |
| 180 | { |
| 181 | // init indentation and node labels |
| 182 | CGPIndentcxx . . $ DlCompletionGraph#CGPIndent. = 0; |
| 183 | std::vectorcxx . . $ std/vector#<bool> tempcxx . . $ std/vector#vector(3413bcf9e068cf98). ( endUsedcxx . . $ DlCompletionGraph#endUsed., false ); |
| 184 | CGPFlagcxx . . $ DlCompletionGraph#CGPFlag..swapcxx . . $ std/vector#swap(a96662affd67f712).(temp); |
| 185 | |
| 186 | const_iteratorcxx . . $ DlCompletionGraph#const_iterator# p = begincxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0).(), p_end = endcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0).(); |
| 187 | unsigned int i = 1; // node id |
| 188 | |
| 189 | // mark all nominals as already printed: they full subtrees will be output with a nominal cloud |
| 190 | for ( ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p; p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end && (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->isNominalNodecxx . . $ DlCompletionTree#isNominalNode(50ce9a9e25b4a850).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p, ++i ) |
| 191 | CGPFlagcxx . . $ DlCompletionGraph#CGPFlag.[cxx . . $ std/vector#`operator[]`(1450282ea0befc17).i] =cxx . . $ std/_Bit_reference#`operator=`(2b7708a91196d621). true; |
| 192 | |
| 193 | // print tree starting from the root node |
| 194 | p =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(1448086951693baf). begincxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0).(); |
| 195 | PrintNodecxx . . $ DlCompletionGraph#PrintNode(dc708c26802d04b9). ( *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p, o ); |
| 196 | |
| 197 | // if there are nominals in the graph -- print the nominal cloud |
| 198 | for ( ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p; p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end && (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->isNominalNodecxx . . $ DlCompletionTree#isNominalNode(50ce9a9e25b4a850).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 199 | { |
| 200 | // print given nominal node in full |
| 201 | CGPFlagcxx . . $ DlCompletionGraph#CGPFlag.[cxx . . $ std/vector#`operator[]`(1450282ea0befc17).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->getIdcxx . . $ DlCompletionTree#getId(ddd8539a2fcdd4ce).()] =cxx . . $ std/_Bit_reference#`operator=`(2b7708a91196d621). false; |
| 202 | PrintNodecxx . . $ DlCompletionGraph#PrintNode(dc708c26802d04b9). ( *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p, o ); |
| 203 | } |
| 204 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 205 | } |
| 206 | |
| 207 | void |
| 208 | DlCompletionGraphcxx . . $ DlCompletionGraph# :: PrintEdgecxx . . $ DlCompletionGraph#PrintEdge(3ed5e198e997ea1). ( DlCompletionTreecxx . . $ DlCompletionTree#::const_edge_iteratorcxx . . $ DlCompletionTree#const_edge_iterator# edge, const DlCompletionTreecxx . . $ DlCompletionTree#* parent, std::ostreamcxx . . $ std/ostream#& o ) |
| 209 | { |
| 210 | const DlCompletionTreecxx . . $ DlCompletionTree#* node = (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).edge)->getArcEndcxx . . $ DlCompletionTreeArc#getArcEnd(1b0634bb62d2788b).(); |
| 211 | bool succEdge = (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).edge)->isSuccEdgecxx . . $ DlCompletionTreeArc#isSuccEdge(50ce9a9e25b4a850).(); |
| 212 | |
| 213 | PrintIndentcxx . . $ DlCompletionGraph#PrintIndent(f7f45734e6842120).(o); |
| 214 | for ( ; edge !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). parent->endcxx . . $ DlCompletionTree#end(d3473f034184ffc9).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).edge ) |
| 215 | if ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).edge)->getArcEndcxx . . $ DlCompletionTreeArc#getArcEnd(1b0634bb62d2788b).() == node && (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).edge)->isSuccEdgecxx . . $ DlCompletionTreeArc#isSuccEdge(50ce9a9e25b4a850).() == succEdge ) |
| 216 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " ", (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).edge)->Printcxx . . $ DlCompletionTreeArc#Print(490063bd7e6d8d5d).(o); // print edge's label |
| 217 | |
| 218 | if ( node == parent ) // print loop |
| 219 | { |
| 220 | PrintIndentcxx . . $ DlCompletionGraph#PrintIndent(f7f45734e6842120).(o); |
| 221 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "-loop to node " <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). parent->getIdcxx . . $ DlCompletionTree#getId(ddd8539a2fcdd4ce).(); |
| 222 | } |
| 223 | else |
| 224 | PrintNodecxx . . $ DlCompletionGraph#PrintNode(dc708c26802d04b9). ( node, o ); |
| 225 | } |
| 226 | |
| 227 | /// print node of the graph with proper indentation |
| 228 | void |
| 229 | DlCompletionGraphcxx . . $ DlCompletionGraph# :: PrintNodecxx . . $ DlCompletionGraph#PrintNode(dc708c26802d04b9). ( const DlCompletionTreecxx . . $ DlCompletionTree#* node, std::ostreamcxx . . $ std/ostream#& o ) |
| 230 | { |
| 231 | if ( CGPIndentcxx . . $ DlCompletionGraph#CGPIndent. ) |
| 232 | { |
| 233 | PrintIndentcxx . . $ DlCompletionGraph#PrintIndent(f7f45734e6842120).(o); |
| 234 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "-"; |
| 235 | } |
| 236 | else |
| 237 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 238 | |
| 239 | node->PrintBodycxx . . $ DlCompletionTree#PrintBody(490063bd7e6d8d5d).(o); // print node's label |
| 240 | |
| 241 | // don't print subtree twice |
| 242 | if ( CGPFlagcxx . . $ DlCompletionGraph#CGPFlag.[cxx . . $ std/vector#`operator[]`(1450282ea0befc17).node->getIdcxx . . $ DlCompletionTree#getId(ddd8539a2fcdd4ce).()] ) |
| 243 | { |
| 244 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "d"; |
| 245 | return; |
| 246 | } |
| 247 | |
| 248 | CGPFlagcxx . . $ DlCompletionGraph#CGPFlag.[cxx . . $ std/vector#`operator[]`(1450282ea0befc17).node->getIdcxx . . $ DlCompletionTree#getId(ddd8539a2fcdd4ce).()] =cxx . . $ std/_Bit_reference#`operator=`(2b7708a91196d621). true; // mark node printed |
| 249 | |
| 250 | // we want to print incoming edges for the nominal cloud |
| 251 | bool wantPred = node->isNominalNodecxx . . $ DlCompletionTree#isNominalNode(50ce9a9e25b4a850).(); |
| 252 | |
| 253 | // print all children |
| 254 | ++CGPIndentcxx . . $ DlCompletionGraph#CGPIndent.; |
| 255 | for ( DlCompletionTreecxx . . $ DlCompletionTree#::const_edge_iteratorcxx . . $ DlCompletionTree#const_edge_iterator# p = node->begincxx . . $ DlCompletionTree#begin(d3473f034184ffc9).(); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). node->endcxx . . $ DlCompletionTree#end(d3473f034184ffc9).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 256 | if ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->isSuccEdgecxx . . $ DlCompletionTreeArc#isSuccEdge(50ce9a9e25b4a850).() || ( wantPred && (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->getArcEndcxx . . $ DlCompletionTreeArc#getArcEnd(1b0634bb62d2788b).()->isNominalNodecxx . . $ DlCompletionTree#isNominalNode(50ce9a9e25b4a850).() ) ) |
| 257 | PrintEdgecxx . . $ DlCompletionGraph#PrintEdge(3ed5e198e997ea1). ( p, node, o ); |
| 258 | --CGPIndentcxx . . $ DlCompletionGraph#CGPIndent.; |
| 259 | } |