| | 124 | |
| | 125 | private List<List<ClassLink>> searchPathsWithCut(OWLQueryBuilderImpl qb){ |
| | 126 | List<List<ClassLink>> paths = new ArrayList<>(); |
| | 127 | ClassLink crrLink = new ClassLink(null,startClass,Direction.both,0); |
| | 128 | List<LinkAndPath> lp = new LinkedList<>(); |
| | 129 | lp.add(new LinkAndPath(crrLink, new LinkedList<ClassLink>())); |
| | 130 | try{ |
| | 131 | for ( int i = 0; i < nsteps; i++ ){ |
| | 132 | ListIterator<LinkAndPath> lit = lp.listIterator(); |
| | 133 | List<LinkAndPath> nextlp = new LinkedList<>(); |
| | 134 | while ( lit.hasNext() ){ |
| | 135 | LinkAndPath crrlp = lit.next(); |
| | 136 | ClassLink[] classLinks = null; |
| | 137 | classLinks = qb.getNextClassViaInstanceLink(null, crrlp.classLink.getLinkedClassURI(), limit); |
| | 138 | for ( int j = 0 ; j < classLinks.length; j++ ){ |
| | 139 | List<ClassLink> crrpath = new LinkedList<>(crrlp.path); |
| | 140 | crrpath.add(classLinks[j]); |
| | 141 | if ( classLinks[j].getLinkedClassURI().equals(endClass) ){ |
| | 142 | paths.add(new LinkedList<>(crrpath)); |
| | 143 | continue; |
| | 144 | } |
| | 145 | boolean con = false; |
| | 146 | double cont = 1.0; |
| | 147 | if ( cont > th ){ // shrink |
| | 148 | con = true; |
| | 149 | } |
| | 150 | if ( crrlp.converge == true && con == false ){ // converge & 縲diverge |
| | 151 | continue; // cut |
| | 152 | } |
| | 153 | nextlp.add(new LinkAndPath(classLinks[j], crrpath, con)); |
| | 154 | } |
| | 155 | } |
| | 156 | lp = nextlp; |
| | 157 | } |
| | 158 | }catch(Exception e){ |
| | 159 | System.err.println(e); |
| | 160 | } |
| | 161 | return paths; |
| | 162 | } |
| | 163 | |