135 | | //private |
136 | | |
137 | | /* |
| 153 | private List<List<ClassLink>> searchPathsbyVisitingNodes(RDFSchemaAnalyzer rdfsa, boolean countLinks){ |
| 154 | List<List<ClassLink>> paths = new ArrayList<>(); |
| 155 | List<LinkAndPath> lp = new LinkedList<>(); |
| 156 | Set<String> urls = new HashSet<String>(); |
| 157 | urls.add(startClass); |
| 158 | lp.add(new LinkAndPath(new ClassLink("",startClass,null,Direction.both,0,0,0,0,0,false,false), |
| 159 | new LinkedList<ClassLink>(), startClass, urls)); |
| 160 | try{ |
| 161 | for ( int i = 0; i < nsteps; i++ ){ |
| 162 | ListIterator<LinkAndPath> lit = lp.listIterator(); |
| 163 | List<LinkAndPath> nextlp = new LinkedList<>(); |
| 164 | while ( lit.hasNext() ){ |
| 165 | LinkAndPath crrlp = lit.next(); |
| 166 | ClassLink[] classLinks = rdfsa.getNextClass(null, crrlp.classLink.getLinkedClassURI(), limit, countLinks); |
| 167 | // limit |
| 168 | for ( int j = 0 ; j < classLinks.length; j++ ){ |
| 169 | if (crrlp.classURIs.contains(classLinks[j].getLinkedClassURI()) ){ |
| 170 | continue; // visited |
| 171 | } |
| 172 | List<ClassLink> crrpath = new LinkedList<>(crrlp.path); |
| 173 | crrpath.add(classLinks[j]); |
| 174 | Set<String> crrurls = new HashSet<String>(crrlp.classURIs); |
| 175 | crrurls.add(classLinks[j].getLinkedClassURI()); |
| 176 | if ( classLinks[j].getLinkedClassURI() == null ){ continue; } |
| 177 | if ( classLinks[j].getNumOfLinks() <= th){ |
| 178 | continue; |
| 179 | } |
| 180 | if ( classLinks[j].getLinkedClassURI().equals(endClass) ){ |
| 181 | paths.add(new LinkedList<>(crrpath)); |
| 182 | continue; |
| 183 | } |
| 184 | //crrlp.classURIs.add() |
| 185 | nextlp.add(new LinkAndPath(classLinks[j], crrpath, crrlp.classLink.getLinkedClassURI(),crrurls)); |
| 186 | } |
| 187 | } |
| 188 | lp = nextlp; |
| 189 | } |
| 190 | }catch(Exception e){ |
| 191 | System.err.println(e); |
| 192 | } |
| 193 | return paths; |
| 194 | } |
| 195 | |
| 196 | /* |
263 | | |
| 322 | /* |
| 323 | public Path[] getPathsByWholeGraph(RDFSchemaAnalyzer rdfsa){ |
| 324 | setWholeGraph(rdfsa); |
| 325 | List<List<ClassLink>> paths = null; |
| 326 | //paths = searchPaths(rdfsa, countLink); |
| 327 | paths = searchPathsbyVisitingNodes(rdfsa, countLink); |
| 328 | NavigableSet<Path> sortedpath = new TreeSet<Path>(); |
| 329 | ListIterator<List<ClassLink>> pit = paths.listIterator(); |
| 330 | int j = 0; |
| 331 | while ( pit.hasNext() ){ |
| 332 | Path path = new Path(); |
| 333 | path.setStartClass(startClass); |
| 334 | List<ClassLink> crrpath = pit.next(); |
| 335 | path.setClassLinks(crrpath); |
| 336 | ListIterator<ClassLink> cit = crrpath.listIterator(); |
| 337 | int min = Integer.MAX_VALUE; |
| 338 | while ( cit.hasNext() ){ |
| 339 | ClassLink cl = cit.next(); |
| 340 | if ( cl.getNumOfLinks() < min ){ |
| 341 | min = cl.getNumOfLinks(); |
| 342 | } |
| 343 | } |
| 344 | path.setWidth(min); |
| 345 | sortedpath.add(path); |
| 346 | j++; |
| 347 | } |
| 348 | Path[] patharray = new Path[paths.size()]; |
| 349 | Iterator<Path> pait = sortedpath.descendingIterator(); |
| 350 | int i = 0; |
| 351 | while ( pait.hasNext() ){ |
| 352 | patharray[i] = pait.next(); |
| 353 | i++; |
| 354 | } |
| 355 | return patharray; |
| 356 | } |
| 357 | */ |