| 130 | List<List<Integer>> simplePaths = searchSimplePaths(snode, enode); |
| 131 | |
| 132 | ListIterator<List<Integer>> pit = simplePaths.listIterator(); |
| 133 | //System.out.println("SPATH:"); |
| 134 | //System.out.println(simplePaths.size()); |
| 135 | while( pit.hasNext()){ |
| 136 | List<Integer> spath = pit.next(); |
| 137 | List<List<ClassLink>> convertedPaths = convertSimplePathToPaths(spath); |
| 138 | paths.addAll(convertedPaths); |
| 139 | } |
| 140 | //System.out.println("PATH:"); |
| 141 | //System.out.println(paths.size()); |
| 142 | return paths; |
| 143 | } |
| 144 | |
| 145 | private List<List<Integer>> searchSimplePaths(Integer snode, Integer enode){ |
| 146 | List<List<Integer>> simplePaths = new LinkedList<>(); |
245 | | /* |
246 | | private List<List<ClassLink>> searchPathsbyVisitingNodes(RDFSchemaAnalyzer rdfsa, boolean countLinks, |
247 | | String startClass, String endClass){ |
248 | | List<List<ClassLink>> paths = new ArrayList<>(); |
249 | | List<LinkAndPath> lp = new LinkedList<>(); |
250 | | Set<String> urls = new HashSet<String>(); |
251 | | urls.add(startClass); |
252 | | lp.add(new LinkAndPath(new ClassLink("",startClass,null,Direction.both,0,0,0,0,0,false,false), |
253 | | new LinkedList<ClassLink>(), startClass, urls)); |
254 | | try{ |
255 | | for ( int i = 0; i < nsteps; i++ ){ |
256 | | ListIterator<LinkAndPath> lit = lp.listIterator(); |
257 | | List<LinkAndPath> nextlp = new LinkedList<>(); |
258 | | while ( lit.hasNext() ){ |
259 | | LinkAndPath crrlp = lit.next(); |
260 | | ClassLink[] classLinks = rdfsa.getNextClass(null, crrlp.classLink.getLinkedClassURI(), limit, countLinks); |
261 | | // limit |
262 | | for ( int j = 0 ; j < classLinks.length; j++ ){ |
263 | | if (crrlp.classURIs.contains(classLinks[j].getLinkedClassURI()) ){ |
264 | | continue; // visited |
265 | | } |
266 | | List<ClassLink> crrpath = new LinkedList<>(crrlp.path); |
267 | | crrpath.add(classLinks[j]); |
268 | | Set<String> crrurls = new HashSet<String>(crrlp.classURIs); |
269 | | crrurls.add(classLinks[j].getLinkedClassURI()); |
270 | | if ( classLinks[j].getLinkedClassURI() == null ){ continue; } |
271 | | if ( classLinks[j].getNumOfLinks() <= th){ |
272 | | continue; |
273 | | } |
274 | | if ( classLinks[j].getLinkedClassURI().equals(endClass) ){ |
275 | | paths.add(new LinkedList<>(crrpath)); |
276 | | continue; |
277 | | } |
278 | | //crrlp.classURIs.add() |
279 | | nextlp.add(new LinkAndPath(classLinks[j], crrpath, crrlp.classLink.getLinkedClassURI(),crrurls)); |
280 | | } |
281 | | } |
282 | | lp = nextlp; |
283 | | } |
284 | | }catch(Exception e){ |
285 | | System.err.println(e); |
286 | | } |
287 | | return paths; |
288 | | } |
289 | | |
| 248 | /* |