Index: /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java
===================================================================
--- /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java (revision 252)
+++ /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java (revision 254)
@@ -12,6 +12,4 @@
 
 public class OWLClassGraph extends LabeledMultiDigraph{
-    //String startClass;
-    //String endClass;
     int nsteps = 4;
     int limit = 100;
@@ -23,5 +21,4 @@
     String sparqlEndpoint;
     Set<Integer> visited;
-    boolean askcheck;
     List<Map<Integer, Integer>> edgeweight;
     List<Integer> nodeweight;
@@ -62,12 +59,10 @@
         super();
         nodeType = new LinkedList<String>();
-        this.askcheck = false;
         setClassGraph(rdfsa);
     }
     
-    public OWLClassGraph(RDFSchemaAnalyzer rdfsa, String sparqlEndpoint, String startClass, boolean askcheck){ // used
+    public OWLClassGraph(RDFSchemaAnalyzer rdfsa, String sparqlEndpoint, String startClass){ // used
         super();
         nodeType = new LinkedList<String>();
-        this.askcheck = askcheck;
         setPartClassGraph(rdfsa, sparqlEndpoint, startClass);
     }
@@ -124,8 +119,4 @@
     }
     
-    public HashSet<Integer> getConnectionList(Integer node){
-        return connectionTable.get(node);
-    }
-
     private List<List<ClassLink>> searchPaths(String startClass, String endClass){
         //int asked = 0;
@@ -168,35 +159,4 @@
                     List<Integer> nextpath = new LinkedList<Integer>(crrpath); // copy
                     nextpath.add(nextnode);
-                    // tmp
-                    if ( i >= 1  && askcheck == true ){
-                        int wn = nodeweight.get(crrnode);
-                        int in = edgeweight.get(crrpath.get(crrpath.size()-2)).get(crrnode);
-                        int out = edgeweight.get(nextnode).get(crrnode);
-                        if ( wn > in + out ){
-                            /*
-                            String key1 = nextnode.toString().concat("-").concat(crrpath.get(crrpath.size()-1).toString())
-                                .concat("-").concat(crrpath.get(crrpath.size()-2).toString());
-                            String key2 = crrpath.get(crrpath.size()-2).toString().concat("-").concat(crrpath.get(crrpath.size()-1).toString())
-                                .concat("-").concat(nextnode.toString());
-                            if ( checkedpaths.containsKey(key1) ){
-                                if ( checkedpaths.get(key1) == false ){
-                                   continue;
-                                }
-                            }else if ( checkedpaths.containsKey(key2) ){
-                                if ( checkedpaths.get(key2) == false ){
-                                   continue;
-                                }
-                            }else{                      
-                                boolean chk = EndpointAccess.check3SimplePath(nextnode, crrpath.get(crrpath.size()-1),
-                                    crrpath.get(crrpath.size()-2), this, sparqlEndpoint);
-                                checkedpaths.put(key1, chk);
-                                if ( chk == false ){
-                                    continue;
-                                }
-                            }
-                            */
-                            continue;
-                        }
-                    }
                     if ( nextnode.equals(enode) ){
                         simplePaths.add(nextpath);
@@ -241,7 +201,7 @@
                     addedpath.add(cl);
                     // check
-                    if (checkPath(startClass, addedpath)){
+                    //if (checkPath(startClass, addedpath)){
                         tmppaths.add(addedpath);
-                    }
+                    //}
                 }
             }
@@ -348,188 +308,28 @@
             }
         }
-    }
-    
-    
-   private ArrayList<HashSet<Integer>> createConnectionTable(){ // not used
-       ArrayList<HashSet<Integer>> ct = new ArrayList<HashSet<Integer>>();
-       for (int i = 0; i < labels.size(); i++ ){ // each node
-           HashSet<Integer> cl = createConnectionList(i);
-           ct.add(cl);
-       }
-       return ct;
-   }
+    }       
    
-   private HashSet<Integer> createConnectionList(Integer node){ // not used 
-       HashSet<Integer> cl = new HashSet<Integer>();
-       HashSet<Integer> crrnodes = new HashSet<Integer>();
-       crrnodes.add(node);
-       cl.add(node);
-       for ( int i = 0 ; i < nsteps; i++ ){
-           Set<Integer> nextnodes = new HashSet<Integer>();
-           Iterator<Integer> cit = crrnodes.iterator();
-           while ( cit.hasNext() ){
-               Integer crr = cit.next();
-               Set<Integer> nexts = gadjlist.get(crr).keySet();
-               Iterator<Integer> nit = nexts.iterator();
-               while ( nit.hasNext() ){
-                   Integer next = nit.next();
-                   if ( !cl.contains(next) ){
-                       nextnodes.add(next);
-                       cl.add(next);
-                   }
-               }
-           }
-           crrnodes.clear();
-           crrnodes.addAll(nextnodes);
-       }
-       return cl;
-   }
-   
-   
-   private void updateWeight(Integer node1, Integer node2, ClassLink edge){
-       Map<Integer, Integer> weight = edgeweight.get(node1);
-       Integer crr = weight.get(node2);
-       if (crr == null ){
-           crr = edge.getNumOfLinkedClassInstances();
-           weight.put(node2, crr);           
-       }
-       if ( crr < edge.getNumOfLinkedClassInstances() ){
-           crr = edge.getNumOfLinkedClassInstances();
-           weight.put(node2, crr);
-       }
-       weight = edgeweight.get(node2);
-       crr = weight.get(node1);
-       if (crr == null ){
-           crr = edge.getNumOfOriginClassInstances();
-           weight.put(node1, crr);
-       }
-       if ( crr < edge.getNumOfOriginClassInstances() ){
-           crr = edge.getNumOfOriginInstances();
-           weight.put(node1, crr);
-       }
-   }
-   
-   private boolean checkPath(String startClass, List<ClassLink> paths){
-       // KOKO
-       return true;
-   }
-   // old codes
-   /*
-    public Path[] getPaths_old(RDFSchemaAnalyzer rdfsa, boolean countLink, String startClass, String endClass){
-        List<List<ClassLink>> paths = null;
-        paths = searchPathsbyVisitingNodes(rdfsa, countLink, startClass, endClass);
-        NavigableSet<Path> sortedpath = new TreeSet<Path>();
-        ListIterator<List<ClassLink>> pit = paths.listIterator();
-        int j = 0;
-        while ( pit.hasNext() ){
-            Path path = new Path();
-            path.setStartClass(startClass);
-            List<ClassLink> crrpath = pit.next();
-            path.setClassLinks(crrpath);
-            ListIterator<ClassLink> cit = crrpath.listIterator();
-            int min = Integer.MAX_VALUE;
-            while ( cit.hasNext() ){
-                ClassLink cl = cit.next();
-                if ( cl.getNumOfLinks() < min ){
-                    min = cl.getNumOfLinks();
-                }
-            }
-            path.setWidth(min);
-            sortedpath.add(path);
-            j++;
-        }
-        Path[] patharray = new Path[paths.size()];
-        Iterator<Path> pait = sortedpath.descendingIterator();
-        int i = 0;
-        while ( pait.hasNext() ){
-            patharray[i] = pait.next();
-            i++;
-        }
-        return patharray;
-    }
-
-    private List<List<ClassLink>> searchPaths_old(String startClass, String endClass){
-
-        List<List<ClassLink>> paths = new ArrayList<>();
-        List<List<Integer>> simplePaths = new LinkedList<>();
-        Integer snode = labelednodes.get(startClass);
-        Integer enode = labelednodes.get(endClass);
-        List<List<Integer>> lp = new LinkedList<>();
-        List<Integer> ini = new LinkedList<Integer>(); // initial path
-        ini.add(snode);
-        lp.add(ini);
-        for (int i = 0; i < nsteps; i++ ){
-            ListIterator<List<Integer>> lit = lp.listIterator();
-            List<List<Integer>> nextlp = new LinkedList<>();
-            while ( lit.hasNext() ){ 
-                List<Integer> crrpath = lit.next();
-                Integer crrnode = crrpath.get(crrpath.size()-1);
-                Set<Integer> nexts = gadjlist.get(crrnode).keySet();
-                Iterator<Integer> nit = nexts.iterator();
-                while( nit.hasNext() ){
-                    Integer nextnode = nit.next();
-                    if ( crrpath.contains(nextnode) ){ continue; }
-                    List<Integer> nextpath = new LinkedList<Integer>(crrpath); // copy
-                    nextpath.add(nextnode);
-                    if ( nextnode.equals(enode) ){
-                        simplePaths.add(nextpath);
-                        continue;
-                    }
-                    nextlp.add(nextpath);
-                }
-	    }
-            lp = nextlp;
-        }
-        
-        ListIterator<List<Integer>> pit = simplePaths.listIterator();
-        while( pit.hasNext()){
-            List<Integer> spath = pit.next();
-            List<List<ClassLink>> convertedPaths = convertSimplePathToPaths(spath);
-            paths.addAll(convertedPaths);
-        }
-        return paths;
-    }   
-    */
-       /*
-    private List<List<ClassLink>> searchPaths(RDFSchemaAnalyzer rdfsa, boolean countLinks){
-        List<List<ClassLink>> paths = new ArrayList<>();
-        List<LinkAndPath> lp = new LinkedList<>();
-        lp.add(new LinkAndPath(new ClassLink("",startClass,null,Direction.both,0,0,0,0,0,false,false), new LinkedList<ClassLink>(), ""));
-        try{
-          for ( int i = 0; i < nsteps; i++ ){
-              ListIterator<LinkAndPath> lit = lp.listIterator();
-              List<LinkAndPath> nextlp = new LinkedList<>();
-              while ( lit.hasNext() ){
-                  LinkAndPath crrlp = lit.next();
-                  ClassLink[] classLinks = rdfsa.getNextClass(null, crrlp.classLink.getLinkedClassURI(), limit, countLinks);
-                  for ( int j = 0 ; j < classLinks.length; j++ ){
-                      List<ClassLink> crrpath = new LinkedList<>(crrlp.path);
-                      crrpath.add(classLinks[j]);
-                      if ( classLinks[j].getLinkedClassURI() == null ){ continue; }
-                      if ( classLinks[j].getLinkedClassURI().equals(endClass) ){
-                          paths.add(new LinkedList<>(crrpath));
-                          continue;
-                      }
-                      if ( countLinks == true && classLinks[j].getNumOfLinks() <= th){
-                          continue;
-                      }
-                      if ( i >= 2 ){
-                          if ( crrlp.classLink.getPropertyURI().equals(classLinks[j].getPropertyURI()) &&
-                           crrlp.classLink.getDirection() != classLinks[j].getDirection() &&
-                           crrlp.originalClassURI.equals( classLinks[j].getLinkedClassURI()) ){
-                              continue;
-                          }
-                      }
-                      nextlp.add(new LinkAndPath(classLinks[j], crrpath, crrlp.classLink.getLinkedClassURI()));
-                  }
-              }
-              lp = nextlp;
-          }
-        }catch(Exception e){ 
-            System.err.println(e);
-        }
-        return paths;  
-    }
-    */
-
+    private void updateWeight(Integer node1, Integer node2, ClassLink edge){
+        Map<Integer, Integer> weight = edgeweight.get(node1);
+        Integer crr = weight.get(node2);
+        if (crr == null ){
+            crr = edge.getNumOfLinkedClassInstances();
+            weight.put(node2, crr);           
+        }
+        if ( crr < edge.getNumOfLinkedClassInstances() ){
+            crr = edge.getNumOfLinkedClassInstances();
+            weight.put(node2, crr);
+        }
+        weight = edgeweight.get(node2);
+        crr = weight.get(node1);
+        if (crr == null ){
+            crr = edge.getNumOfOriginClassInstances();
+            weight.put(node1, crr);
+        }
+        if ( crr < edge.getNumOfOriginClassInstances() ){
+            crr = edge.getNumOfOriginInstances();
+            weight.put(node1, crr);
+        }
+    }
+    
 }
Index: /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/SimpleTree.java
===================================================================
--- /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/SimpleTree.java (revision 133)
+++ /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/SimpleTree.java (revision 254)
@@ -122,5 +122,5 @@
 	     * 
 	    */
-	    
+	    /*
 	    public static void main (String[] args) {
 
@@ -145,5 +145,5 @@
 	       
 
-	    }
+	    }*/
 	
 }
Index: /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/StructureCrawler.java
===================================================================
--- /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/StructureCrawler.java (revision 133)
+++ /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/StructureCrawler.java (revision 254)
@@ -15,4 +15,5 @@
 
 	// this is just for a test
+        /*
 	public static void main(String[] args) throws Exception{
 		StructureCrawler sc = new StructureCrawler(new File("c:\\cdata"));
@@ -29,5 +30,5 @@
 		}
 	}
-	
+	*/
 	
 	
Index: /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/ClassLink.java
===================================================================
--- /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/ClassLink.java (revision 221)
+++ /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/ClassLink.java (revision 254)
@@ -166,5 +166,53 @@
 		return json_str;
 	}
-	
+
+	public String toJSONString4(QueryPathGenerator qpg) {
+		String json_str ="{";
+		
+		if( propertyURI != null ) {
+			//json_str+="\"propertyURI\":"+"\""+propertyURI+"\",";
+                    json_str+="\"predicate\":"+"\""+propertyURI+"\",";
+		}
+		else{
+			json_str+="\"predicate\":"+"\"propertyURI\",";			
+		}
+		if( linkedClassURI != null ){
+			//json_str+="\"linkedClassURI\":"+"\""+linkedClassURI+"\",";
+                    json_str+="\"linkedClass\":"+"\""+linkedClassURI+"\",";
+		}
+		else{
+			//json_str+="\"linkedClassURI\":"+"\"linkedClassURI\",";	
+                    json_str+="\"linkedClass\":"+"\""+linkedClassURI+"\",";
+		}
+		if( linkedLiteralDatatypeURI != null ){
+			json_str+="\"linkedLiteralDatatypeURI\":"+"\""+linkedLiteralDatatypeURI+"\",";
+		}
+		else{
+			json_str+="\"linkedLiteralDatatypeURI\":"+"\"linkedLiteralDatatypeURI\",";			
+		}
+                if( direction != null ){
+			json_str+="\"direction\":"+"\""+direction.toString()+"\",";
+		}
+		else{
+			json_str+="\"direction\":"+"\"direction\",";			
+		}
+                if ( linkedClassURI != null ){
+                    String label = qpg.getClassLabel(linkedClassURI);
+                    json_str+="\"label\":"+"\""+label+"\"";
+                }else if ( linkedLiteralDatatypeURI != null ){
+                    String url[] = linkedLiteralDatatypeURI.split("/");
+                    String tmplabel = url[url.length-1];
+                    String[] tmplabel2 = tmplabel.split("#");
+                    String label = tmplabel2[tmplabel2.length-1];
+                    json_str+="\"label\":"+"\""+label+"\"";          
+                }else{
+                    json_str+="\"label\":"+"\""+"\"No Label\""+"\"";               
+                }
+		json_str+="}";
+
+		return json_str;
+	}
+        
+        
 	public int getNumOfLinks() {
 		return numOfLinks;
Index: /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLLabelReader.java
===================================================================
--- /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLLabelReader.java (revision 254)
+++ /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLLabelReader.java (revision 254)
@@ -0,0 +1,43 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.biohackathon.SPARQLBuilder.OWL;
+
+/**
+ *
+ * @author atsuko
+ */
+
+import java.util.*;
+import java.io.*;
+
+public class OWLLabelReader {
+    static Map<String, String> readLabels(String dir){
+        Map<String, String> labels = new HashMap<String, String> ();
+        File fdir = new File(dir);
+        if ( fdir.exists() ){
+            File[] files = fdir.listFiles();
+            for (int i = 0 ; i < files.length; i++ ){
+                try{
+                    BufferedReader in = new BufferedReader(new FileReader(files[i]));
+                    String buf;
+                    while( (buf = in.readLine()) != null){
+                        String[] data = buf.split("[\\s]+");
+                        if ( data[1].equals("<http://www.w3.org/2000/01/rdf-schema#label>") ){
+                            String[] lit = data[2].split("\"");                            
+                            labels.put(data[0].substring(1,data[0].length() -1 ), lit[1]);
+                            //System.out.println(data[0].substring(1,data[0].length() -1 ));
+                            //System.out.println(lit[1]);
+                        }
+                    }
+                    in.close();
+                }catch(IOException e){
+                    System.err.println(e);
+                }
+            }
+        }
+        return labels;
+    }
+}
Index: /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/AcquiredStructureAnalyzer.java
===================================================================
--- /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/AcquiredStructureAnalyzer.java (revision 173)
+++ /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/AcquiredStructureAnalyzer.java (revision 254)
@@ -33,5 +33,5 @@
 	}
 	
-	
+	/*
 	public static void main(String[] args) throws Exception{
 
@@ -56,5 +56,5 @@
 		
 	}
-	
+	*/
 	
 	public AcquiredStructureAnalyzer(String endpointURI, String[] graphURIs, Model model){
Index: /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/QueryPathGenerator.java
===================================================================
--- /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/QueryPathGenerator.java (revision 251)
+++ /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/QueryPathGenerator.java (revision 254)
@@ -20,8 +20,11 @@
     private RDFSchemaAnalyzer analyzer = null;
     private OWLClassGraph graph;
-    private boolean askcheck;
+
+    private Map<String, String> clabels;
     
     private static final String CDIR = "cdata";
-        
+    private static final String ODIR = "owldata";
+        
+    /*
     public static void main(String[] args){
         QueryPathGenerator qpg = new QueryPathGenerator();
@@ -87,4 +90,5 @@
         }
     }
+    */
     
     public QueryPathGenerator(){
@@ -98,6 +102,5 @@
     
     public void setOWLClassGraph(String startClass){
-        //graph = new OWLClassGraph(analyzer, sparqlEndpoint, startClass, askcheck);
-        graph = new OWLClassGraph(analyzer, sparqlEndpoint, startClass, true);
+        graph = new OWLClassGraph(analyzer, sparqlEndpoint, startClass);
     }
     
@@ -123,5 +126,4 @@
             setOWLClassGraph(startClass);
         }
-        graph.askcheck = askcheck;
         return graph.getPaths(startClass, endClass);
     }
@@ -144,4 +146,39 @@
     }
     
+    public String getClassLabel(String classURI){
+        return clabels.get(classURI);
+    }
+    
+    public void setClassLabels(SClass[] classes){
+        clabels = new HashMap<String, String>();
+        Map<String, String> extLabels = getClassLabelsFromExternal();
+        
+        for ( int i = 0 ; i < classes.length; i++ ){
+            String classURI = classes[i].getClassURI();
+
+            Label[] labels = classes[i].getLabels();
+            String label = null;
+            for ( int j = 0 ; j < labels.length; j++ ){
+                if ( labels[j].getLanguage() == null ){
+                    label = labels[j].getLabel(); 
+                    break;
+                }else if ( labels[j].getLanguage().equals("en") || labels[j].getLanguage().equals("") ){
+                    label = labels[j].getLabel(); 
+                    break;
+                }
+            }
+            if ( label == null ){
+                label = extLabels.get(classURI);
+            }
+            if ( label == null ){
+                String[] uris = classURI.split("/");
+                String tmplabel = uris[uris.length-1];
+                String[] tmplabel2 = tmplabel.split("#");
+                label = tmplabel2[tmplabel2.length-1];
+            }
+            clabels.put(classURI, label);
+        }
+    }
+
     public static String getClassLabelfromList(String classURI, SClass[] classes){
         if ( classURI == null ){
@@ -152,5 +189,5 @@
             if ( classURI.equals(classes[i].getClassURI()) ){
                 return getClassLabelfromClass(classes[i]);
-            }                    
+            }
         }
         return "";
@@ -173,4 +210,8 @@
     }
         
+    public Map<String, String> getClassLabelsFromExternal(){
+        return  OWLLabelReader.readLabels(ODIR);
+    }
+    
     public OWLClassGraph getOWLClassGraph(){
         /*if ( graph == null ){
Index: /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/Path.java
===================================================================
--- /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/Path.java (revision 251)
+++ /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/Path.java (revision 254)
@@ -78,5 +78,5 @@
                 // label
                 json_str+="\"label\":\""+QueryPathGenerator.getClassLabelfromList(startClass, classes)+"\",";
-		if (classLinks != null && classLinks.size() != 0) {
+                if (classLinks != null && classLinks.size() != 0) {
 			json_str+="\"classLinks\":[";
 			
@@ -95,4 +95,25 @@
 	}
 
+	public String toJSONString4(QueryPathGenerator qpg){
+		String json_str="";
+		json_str+="{\"startClass\":\""+ startClass+"\",";
+                // label
+                json_str+="\"label\":\""+qpg.getClassLabel(startClass)+"\",";
+                if (classLinks != null && classLinks.size() != 0) {
+			json_str+="\"classLinks\":[";
+			
+			JSONObject[] classLinkObjs = new JSONObject[classLinks.size()];
+			for (int i = 0; i < classLinks.size(); i++) {
+				if(i>0){json_str += "," ;}
+				json_str+= classLinks.get(i).toJSONString4(qpg);
+			}
+			json_str+="]";                        
+		}
+                json_str += ",";
+                json_str +="\"score\":\""+width+"\"";
+		json_str +="}";
+		
+		return json_str;
+	}
         
 	public String getStartClass() {
