| 386 | |
| 387 | public void setPartClassGraph(RDFSchemaAnalyzer rdfsa, String startClass){ |
| 388 | // setNodes |
| 389 | SClass[] classes = null; |
| 390 | try{ |
| 391 | classes = rdfsa.getOWLClasses(null, null, null, true); |
| 392 | }catch(Exception e){ |
| 393 | System.err.println(e); return; |
| 394 | } |
| 395 | for (int i = 0 ; i < classes.length; i++){ |
| 396 | addNode(classes[i].getClassURI()); |
| 397 | nodeType.add("class"); |
| 398 | } |
| 399 | int nedge = 0; |
| 400 | Integer snode = labelednodes.get(startClass); |
| 401 | Set<Integer> nodes = new HashSet<Integer>(); |
| 402 | nodes.add(snode); |
| 403 | Set<Integer> visited = new HashSet<Integer>(); |
| 404 | for (int i = 0 ; i < nsteps; i++ ){ |
| 405 | Iterator<Integer> nit = nodes.iterator(); |
| 406 | Set<Integer> nextnodes = new HashSet<Integer>(); |
| 407 | while ( nit.hasNext() ){ |
| 408 | Integer crr = nit.next(); |
| 409 | visited.add(crr); |
| 410 | try{ |
| 411 | ClassLink[] classLinks = rdfsa.getNextClass(null, labels.get(crr), limit, true); |
| 412 | for (int j = 0 ; j < classLinks.length; j++){ |
| 413 | Integer nn = labelednodes.get(classLinks[j].getLinkedClassURI()); |
| 414 | if ( !visited.contains(nn) ){ |
| 415 | nextnodes.add(nn); |
| 416 | } |
| 417 | if ( nn != null ){ |
| 418 | addEdge(crr, nn, classLinks[j]); |
| 419 | /* |
| 420 | }else{ |
| 421 | nn = labelednodes.get(classLinks[j].getLinkedLiteralDatatypeURI()); |
| 422 | if ( nn == null ){ |
| 423 | addNode(classLinks[j].getLinkedLiteralDatatypeURI()); |
| 424 | n = nodeType.size(); |
| 425 | nodeType.add("literal"); |
| 426 | } |
| 427 | addEdge(i, n, classLinks[j]); |
| 428 | /* |
| 429 | ClassLink rev = new ClassLink( classLinks[j].getPropertyURI(), |
| 430 | //classLinks[j].getLinkedClassURI(), |
| 431 | classes[i].getClassURI(), |
| 432 | classLinks[j].getLinkedLiteralDatatypeURI(), |
| 433 | classLinks[j].getDirection(), classLinks[j].getNumOfLinks(), |
| 434 | classLinks[j].getNumOfOriginInstances(), classLinks[j].getNumOfLinkedInstances(), |
| 435 | classLinks[j].getNumOfOriginClassInstances(), classLinks[j].getNumOfLinkedClassInstances(), |
| 436 | classLinks[j].isDomainClassLimitedQ(), classLinks[j].isRangeClassLimitedQ() ); |
| 437 | rev.setDirection(Direction.reverse); |
| 438 | addEdge(n, i, rev); |
| 439 | */ |
| 440 | } |
| 441 | } |
| 442 | }catch(Exception e){ |
| 443 | e.printStackTrace(); |
| 444 | } |
| 445 | } |
| 446 | nodes = nextnodes; |
| 447 | } |
| 448 | } |