チェンジセット 45 : BH13SPARQLBuilder/src/org
- 更新日時:
- 2014/02/17 15:40:07 (11 年 前)
- ファイル:
-
- 1 変更
凡例:
- 変更なし
- 追加
- 削除
-
BH13SPARQLBuilder/src/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java
r41 r45 17 17 int limit; 18 18 int th; 19 double cut; 19 20 20 21 public class LinkAndPath{ 21 22 ClassLink classLink; 22 23 List<ClassLink> path; 24 boolean converge; 23 25 public LinkAndPath(ClassLink classLink, List<ClassLink> path){ 24 26 this.classLink = classLink; 25 27 this.path = path; 28 this.converge = false; 29 } 30 31 public LinkAndPath(ClassLink classLink, List<ClassLink> path, boolean converge){ 32 this.classLink = classLink; 33 this.path = path; 34 this.converge = converge; 26 35 } 27 36 } … … 36 45 limit = 1000; 37 46 th = 0; 47 cut = 2.0; 38 48 } 39 49 … … 73 83 return patharray; 74 84 } 75 76 /* 77 private List<List<ClassLink>> searchPathsFromOWL(OWLQueryBuilderImpl qb){ 78 return searchPathsEngine(qb, 0); 79 } 80 81 private List<List<ClassLink>> searchPathsFromInstances(OWLQueryBuilderImpl qb){ 82 return searchPathsEngine(qb, 1); 83 } 84 */ 85 85 86 86 private List<List<ClassLink>> searchPaths(OWLQueryBuilderImpl qb, int mode, boolean countLinks){ 87 87 List<List<ClassLink>> paths = new ArrayList<>(); … … 122 122 return paths; 123 123 } 124 125 private List<List<ClassLink>> searchPathsWithCut(OWLQueryBuilderImpl qb){ 126 List<List<ClassLink>> paths = new ArrayList<>(); 127 ClassLink crrLink = new ClassLink(null,startClass,Direction.both,0); 128 List<LinkAndPath> lp = new LinkedList<>(); 129 lp.add(new LinkAndPath(crrLink, new LinkedList<ClassLink>())); 130 try{ 131 for ( int i = 0; i < nsteps; i++ ){ 132 ListIterator<LinkAndPath> lit = lp.listIterator(); 133 List<LinkAndPath> nextlp = new LinkedList<>(); 134 while ( lit.hasNext() ){ 135 LinkAndPath crrlp = lit.next(); 136 ClassLink[] classLinks = null; 137 classLinks = qb.getNextClassViaInstanceLink(null, crrlp.classLink.getLinkedClassURI(), limit); 138 for ( int j = 0 ; j < classLinks.length; j++ ){ 139 List<ClassLink> crrpath = new LinkedList<>(crrlp.path); 140 crrpath.add(classLinks[j]); 141 if ( classLinks[j].getLinkedClassURI().equals(endClass) ){ 142 paths.add(new LinkedList<>(crrpath)); 143 continue; 144 } 145 boolean con = false; 146 double cont = 1.0; 147 if ( cont > th ){ // shrink 148 con = true; 149 } 150 if ( crrlp.converge == true && con == false ){ // converge & 縲diverge 151 continue; // cut 152 } 153 nextlp.add(new LinkAndPath(classLinks[j], crrpath, con)); 154 } 155 } 156 lp = nextlp; 157 } 158 }catch(Exception e){ 159 System.err.println(e); 160 } 161 return paths; 162 } 163 124 164 }