チェンジセット 249 : SPARQLBuilderWWW/src/java/org
- 更新日時:
- 2015/04/02 15:31:01 (10 年 前)
- ファイル:
-
- 1 変更
凡例:
- 変更なし
- 追加
- 削除
-
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java
r248 r249 126 126 Map<String,Boolean> checkedpaths = new HashMap<String, Boolean>(); 127 127 List<List<ClassLink>> paths = new ArrayList<>(); 128 List<List<Integer>> simplePaths = new LinkedList<>();129 128 Integer snode = labelednodes.get(startClass); 130 129 Integer enode = labelednodes.get(endClass); 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<>(); 131 147 List<List<Integer>> lp = new LinkedList<>(); 132 148 List<Integer> ini = new LinkedList<Integer>(); // initial path … … 185 201 } 186 202 lp = nextlp; 187 } 188 189 ListIterator<List<Integer>> pit = simplePaths.listIterator(); 190 //int i = 0; 191 //int j = 0; 192 System.out.println("SPATH:"); 193 System.out.println(simplePaths.size()); 194 while( pit.hasNext()){ 195 List<Integer> spath = pit.next(); 196 List<List<ClassLink>> convertedPaths = convertSimplePathToPaths(spath); 197 paths.addAll(convertedPaths); 198 } 199 System.out.println("PATH:"); 200 System.out.println(paths.size()); 201 return paths; 202 } 203 203 } 204 return simplePaths; 205 } 206 204 207 205 208 private List<List<ClassLink>> convertSimplePathToPaths(List<Integer> simplePath){ … … 243 246 } 244 247 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 /* 290 249 private void setClassGraph(RDFSchemaAnalyzer rdfsa){ 291 250 // setNodes … … 327 286 // set endpoint 328 287 this.sparqlEndpoint = sparqlEndpoint; 329 330 288 visited = new HashSet<Integer>(); 331 289 edgeweight = new LinkedList<Map<Integer,Integer>>(); … … 345 303 } 346 304 // setEdges 347 //int nedge = 0;348 305 Integer snode = labelednodes.get(startClass); 349 306 Set<Integer> nodes = new HashSet<Integer>(); … … 375 332 visited.addAll(nodes); 376 333 } 377 } 378 334 // cut visited 335 Iterator<Integer> nit = visited.iterator(); 336 while(nit.hasNext()){ 337 Integer node = nit.next(); 338 if ( ! node.equals(snode) ){ 339 List<List<Integer>> paths = searchSimplePaths(snode, node); 340 if ( paths.isEmpty()){ 341 nit.remove(); 342 } 343 } 344 } 345 } 346 347 379 348 private ArrayList<HashSet<Integer>> createConnectionTable(){ // not used 380 349 ArrayList<HashSet<Integer>> ct = new ArrayList<HashSet<Integer>>();