21 | | /* |
22 | | public class LinkAndPath{ |
23 | | String originalClassURI; // originalClasssURI -classLink.propertyURI-> classLink.linkedClassURL |
24 | | ClassLink classLink; |
25 | | List<ClassLink> path; |
26 | | Set<String> classURIs; // apearing class URIs in the path |
27 | | |
28 | | |
29 | | public LinkAndPath(ClassLink classLink, List<ClassLink> path){ |
30 | | this.classLink = classLink; |
31 | | this.path = path; |
32 | | } |
33 | | |
34 | | public LinkAndPath(ClassLink classLink, List<ClassLink> path, String originalClassURI){ |
35 | | this.classLink = classLink; |
36 | | this.path = path; |
37 | | this.originalClassURI = originalClassURI; |
38 | | } |
39 | | |
40 | | public LinkAndPath(ClassLink classLink, List<ClassLink> path, String originalClassURI, Set<String> classURIs){ |
41 | | this.classLink = classLink; |
42 | | this.path = path; |
43 | | this.originalClassURI = originalClassURI; |
44 | | this.classURIs = classURIs; |
45 | | } |
46 | | }*/ |
47 | | |
235 | | } |
236 | | |
237 | | /* |
238 | | public void setPartClassGraph(RDFSchemaAnalyzer rdfsa, String sparqlEndpoint, String startClass){ |
239 | | // set endpoint |
240 | | this.sparqlEndpoint = sparqlEndpoint; |
241 | | visited = new HashSet<Integer>(); |
242 | | edgeweight = new LinkedList<Map<Integer,Integer>>(); |
243 | | nodeweight = new LinkedList<Integer>(); |
244 | | // setNodes for all classes |
245 | | SClass[] classes = null; |
246 | | try{ |
247 | | classes = rdfsa.getOWLClasses(null, null, null, true); |
248 | | }catch(Exception e){ |
249 | | System.err.println(e); return; |
250 | | } |
251 | | for (int i = 0 ; i < classes.length; i++){ |
252 | | addNode(classes[i].getClassURI()); |
253 | | nodeType.add("class"); |
254 | | edgeweight.add(new HashMap<Integer,Integer>()); |
255 | | nodeweight.add(classes[i].getNumOfInstances()); |
256 | | } |
257 | | // setEdges |
258 | | Integer snode = labelednodes.get(startClass); |
259 | | Set<Integer> nodes = new HashSet<Integer>(); |
260 | | nodes.add(snode); |
261 | | visited.add(snode); |
262 | | for (int i = 0 ; i < nsteps; i++ ){ |
263 | | Iterator<Integer> nit = nodes.iterator(); |
264 | | Set<Integer> nextnodes = new HashSet<Integer>(); |
265 | | while ( nit.hasNext() ){ |
266 | | Integer crr = nit.next(); |
267 | | try{ |
268 | | ClassLink[] classLinks = rdfsa.getNextClass(null, labels.get(crr), limit, true); |
269 | | for (int j = 0 ; j < classLinks.length; j++){ |
270 | | Integer nn = labelednodes.get(classLinks[j].getLinkedClassURI()); |
271 | | if ( nn == null ){ |
272 | | continue; |
273 | | } |
274 | | if ( !visited.contains(nn) ){ |
275 | | nextnodes.add(nn); |
276 | | } |
277 | | addEdge(crr, nn, classLinks[j]); |
278 | | updateWeight(crr, nn, classLinks[j]); |
279 | | } |
280 | | }catch(Exception e){ |
281 | | e.printStackTrace(); |
282 | | } |
283 | | } |
284 | | nodes = nextnodes; |
285 | | visited.addAll(nodes); |
286 | | } |
287 | | // cut visited |
288 | | Iterator<Integer> nit = visited.iterator(); |
289 | | while(nit.hasNext()){ |
290 | | Integer node = nit.next(); |
291 | | if ( ! node.equals(snode) ){ |
292 | | List<List<Integer>> paths = searchSimplePaths(snode, node); |
293 | | if ( paths.isEmpty()){ |
294 | | nit.remove(); |
295 | | } |
296 | | } |
297 | | } |
298 | | } |
299 | | */ |
300 | | /* |
301 | | private void updateWeight(Integer node1, Integer node2, ClassLink edge){ |
302 | | Map<Integer, Integer> weight = edgeweight.get(node1); |
303 | | Integer crr = weight.get(node2); |
304 | | if (crr == null ){ |
305 | | crr = edge.getNumOfLinkedClassInstances(); |
306 | | weight.put(node2, crr); |
307 | | } |
308 | | if ( crr < edge.getNumOfLinkedClassInstances() ){ |
309 | | crr = edge.getNumOfLinkedClassInstances(); |
310 | | weight.put(node2, crr); |
311 | | } |
312 | | weight = edgeweight.get(node2); |
313 | | crr = weight.get(node1); |
314 | | if (crr == null ){ |
315 | | crr = edge.getNumOfOriginClassInstances(); |
316 | | weight.put(node1, crr); |
317 | | } |
318 | | if ( crr < edge.getNumOfOriginClassInstances() ){ |
319 | | crr = edge.getNumOfOriginInstances(); |
320 | | weight.put(node1, crr); |
321 | | } |
322 | | } |
323 | | |
324 | | public List<String> getReachableClasses(){ |
325 | | List<String> clURIs = new LinkedList<String>(); |
326 | | if ( visited == null ){ |
327 | | return null; |
328 | | } |
329 | | Iterator<Integer> vit = visited.iterator(); |
330 | | while( vit.hasNext() ){ |
331 | | Integer vn = vit.next(); |
332 | | clURIs.add(labels.get(vn)); |
333 | | } |
334 | | return clURIs; |
335 | | } |
336 | | */ |
| 192 | } |