Index: /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java
===================================================================
--- /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java (revision 280)
+++ /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java (revision 281)
@@ -99,7 +99,10 @@
                 }
             }
+            path.setMin(min);
             // using length of path
             //int rankwidth = (int) ( ( min * nsteps )/ crrpath.size() );
-            path.setWidth(500000 - crrpath.size()*100000 - min);
+            //path.setWidth(500000 - crrpath.size()*100000 - min);
+            double prob = computePrOfPath(path);
+            path.setWidth(prob);
             sortedpaths.add(path);
             j++;
@@ -280,4 +283,5 @@
                         if ( !visited.contains(nn) ){
                             nextnodes.add(nn);
+                            //visited.add(nn);
                         }
                         addEdge(crr, nn, classLinks[j]);
@@ -305,30 +309,5 @@
         */
     }
-   
-    /*
-    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);
-        }
-    }
-    */
-    
+       
     public List<String> getReachableClasses(){
         List<String> clURIs = new LinkedList<String>();
@@ -348,24 +327,33 @@
         ClassLink prev = lit.next();
         double prob = 1.0;
+        boolean chk = true;
+        double c1, c2; 
         while( lit.hasNext() ){
             ClassLink crr = lit.next();
-            double prob2 = 1.0 -
-                    ((double) ( crr.getNumOfOriginClassInstances())/ 
-                    (double) (  nodeweight.get(labelednodes.get(prev.getLinkedClassURI())) ));
-            if ( prob2 > 1.0 ){
-                System.out.println("Prob2 > 1");
-                System.out.println(prev.getLinkedClassURI());
+            c1 = (double) ( crr.getNumOfOriginClassInstances()) / 
+                    (double) (  nodeweight.get(labelednodes.get(prev.getLinkedClassURI())));
+            c2 = (double) ( prev.getNumOfLinkedClassInstances()) / 
+                    (double) (  nodeweight.get(labelednodes.get(prev.getLinkedClassURI())));
+            if ( c1 < 0.5 && c2 < 0.5 ){ chk = false;}
+            double prob2 = 1.0 - c1;
+                    //((double) ( crr.getNumOfOriginClassInstances())/ 
+                    //(double) (  nodeweight.get(labelednodes.get(prev.getLinkedClassURI())) ));
+            //if ( prob2 > 1.0 || prob2 < 0 ){
+            //    System.out.println("Prob2 > 1 or Prob2 < 0");
+            //    System.out.println(prev.getLinkedClassURI());
                 //classes[labelednodes.get(prev.getLinkedClassURI())].getNumOfInstances();
-                System.out.println(prev.getPropertyURI());
-            }
+            //    System.out.println(prev.getPropertyURI());
+            //}
             double prob3 = 1.0 - Math.pow(prob2, (double) prev.getNumOfLinkedClassInstances());
-            if ( prob3 > 1.0 ){
-                System.out.println("Prob3 > 1");
-                System.out.println(prev.getLinkedClassURI());
+            //if ( prob3 > 1.0 ){
+            //    System.out.println("Prob3 > 1");
+            //    System.out.println(prev.getLinkedClassURI());
                 //classes[labelednodes.get(prev.getLinkedClassURI())].getNumOfInstances();
-                System.out.println(prev.getPropertyURI());
-            }
+            //    System.out.println(prev.getPropertyURI());
+            //}
             prob = prob * prob3 ;
-        }
+            prev = crr;
+        }
+        path.setChk(chk);
         return prob;
     }
Index: /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/Path.java
===================================================================
--- /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/Path.java (revision 259)
+++ /SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/Path.java (revision 281)
@@ -20,5 +20,8 @@
 	 */
 	private String startClass;
-	private int width;
+	//private int width;
+        private float width;
+        private int min;
+        private boolean chk;
 
 	/**
@@ -111,5 +114,6 @@
 		}
                 json_str += ",";
-                json_str +="\"score\":\""+width+"\"";
+                //json_str +="\"score\":\""+width+"\"";
+                json_str +="\"score\":\""+""+"\"";
 		json_str +="}";
 		
@@ -132,5 +136,5 @@
 	}
 
-	public int getWidth() {
+	public float getWidth() {
 		return width;
 	}
@@ -157,7 +161,42 @@
 	}
 
+	public void setWidth(double width) {
+		this.width = (float) width;
+	}
+        
+        public void setMin(int min){
+            this.min = min;
+        }
+        
+        public int getMin(){
+            return min;
+        }
+        
+        public void setChk(boolean chk){
+            this.chk = chk;
+        }
+        
+        public boolean getChk(){
+            return chk;
+        }
+                
     @Override
     public int compareTo(Path path) {
-        return this.width - path.getWidth() ;
+        if ( this.width - path.getWidth() > 0 ){ return 1; }
+        else if ( this.width - path.getWidth() < 0 ){ return -1; }
+        else { 
+            if ( this.chk == true && path.getChk() == false ){ return 1; }
+            if ( this.chk == false && path.getChk() == true ){ return -1; }
+            else {
+                if ( path.classLinks.size() - this.classLinks.size() > 0 ){ return 1;}
+                else if ( path.classLinks.size() - this.classLinks.size() < 0 ){ return -1;}
+                else{ 
+                    if ( this.min - path.getMin() > 0 ){ return 1; }
+                    else if ( this.min - path.getMin() < 0 ){ return -1;}
+                    return 0;
+                }
+            }
+        }
+        //return this.width - path.getWidth() ;
         //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
     }
