チェンジセット 273 : SPARQLBuilderWWW2016/src/java/org/biohackathon/SPARQLBuilder/OWL/LabeledMultiDigraph.java
- 更新日時:
- 2016/03/15 18:40:34 (9 年 前)
- ファイル:
-
- 1 変更
凡例:
- 変更なし
- 追加
- 削除
-
SPARQLBuilderWWW2016/src/java/org/biohackathon/SPARQLBuilder/OWL/LabeledMultiDigraph.java
r267 r273 13 13 14 14 public class LabeledMultiDigraph { 15 List<List<LabeledEdge>> adjlist; 15 //List<List<LabeledEdge>> adjlist; 16 List<Map<Integer,List<LabeledEdge>>> labelededges; 16 17 List<String> labels; 17 18 HashMap<String,Integer> labelednodes; 18 List<Map<Integer,List<LabeledEdge>>> gadjlist; // grouped adj list: node, node-edge list19 //List<Map<Integer,List<LabeledEdge>>> gadjlist; // grouped adj list: node, node-edge list 19 20 20 21 public class LabeledEdge{ 21 Integer node;22 boolean direction; 22 23 Object label; 23 24 24 public LabeledEdge( Integer node, Object label){25 this. node = node;25 public LabeledEdge(boolean dir, Object label){ 26 this.direction = dir; 26 27 this.label = label; 27 28 } … … 33 34 34 35 public LabeledMultiDigraph(){ 35 adjlist = new ArrayList<List<LabeledEdge>>(); 36 //adjlist = new ArrayList<List<LabeledEdge>>(); 37 labelededges = new ArrayList<Map<Integer,List<LabeledEdge>>>(); 36 38 labels = new LinkedList<String>(); 37 39 labelednodes = new HashMap<String, Integer>(); 38 gadjlist = new ArrayList<Map<Integer,List<LabeledEdge>>>();40 //gadjlist = new ArrayList<Map<Integer,List<LabeledEdge>>>(); 39 41 } 40 42 … … 42 44 labelednodes.put(label, labels.size()); 43 45 labels.add(label); 44 adjlist.add(new LinkedList<LabeledEdge>()); 45 gadjlist.add(new HashMap<Integer, List<LabeledEdge>>()); 46 //adjlist.add(new LinkedList<LabeledEdge>()); 47 //gadjlist.add(new HashMap<Integer, List<LabeledEdge>>()); 48 labelededges.add(new HashMap<Integer, List<LabeledEdge>>()); 46 49 } 47 50 48 public void addEdge(Integer node1, Integer node2, Object elabel){ 51 public void addEdge(Integer node1, Integer node2, Object elabel){ // node 1 -> node2 49 52 if ( labels.size() < node1 || labels.size() < node2 ){ 50 53 System.err.println("Error for Edge Addition: No Node for the Edge"); 51 54 return; 52 55 } 53 LabeledEdge edge = new LabeledEdge(node2, elabel);54 adjlist.get(node1).add(edge);55 56 56 Map<Integer, List<LabeledEdge>> edges = gadjlist.get(node1); 57 List<LabeledEdge> sedge = edges.get(node2); 58 if ( sedge == null ){ 59 sedge = new LinkedList<LabeledEdge>(); 60 edges.put(node2, sedge); 57 //LabeledEdge edge = new LabeledEdge(node2,elabel); 58 //adjlist.get(node1).add(edge); 59 List<LabeledEdge> edgesf = labelededges.get(node1).get(node2); 60 if ( edgesf == null ){ 61 edgesf = new LinkedList<LabeledEdge>(); 62 labelededges.get(node1).put(node2, edgesf); 61 63 } 62 sedge.add(edge); 64 edgesf.add(new LabeledEdge(true, elabel)); 65 66 List<LabeledEdge> edgesr = labelededges.get(node2).get(node1); 67 if ( edgesr == null ){ 68 edgesr = new LinkedList<LabeledEdge>(); 69 labelededges.get(node2).put(node1, edgesr); 70 } 71 edgesr.add(new LabeledEdge(false, elabel)); 63 72 } 64 73 }