1 | /* |
---|
2 | * To change this template, choose Tools | Templates |
---|
3 | * and open the template in the editor. |
---|
4 | */ |
---|
5 | package org.biohackathon.SPARQLBuilder.OWL; |
---|
6 | |
---|
7 | /** |
---|
8 | * |
---|
9 | * @author atsuko |
---|
10 | */ |
---|
11 | import java.util.*; |
---|
12 | |
---|
13 | |
---|
14 | public class LabeledMultiDigraph { |
---|
15 | List<List<LabeledEdge>> adjlist; |
---|
16 | List<String> labels; |
---|
17 | HashMap<String,Integer> labelednodes; |
---|
18 | |
---|
19 | public class LabeledEdge{ |
---|
20 | Integer node; |
---|
21 | String label; |
---|
22 | Direction direction; |
---|
23 | Integer ntriples; |
---|
24 | |
---|
25 | public LabeledEdge(Integer node, String label, Direction direction, Integer ntriples){ |
---|
26 | this.node = node; |
---|
27 | this.label = label; |
---|
28 | this.direction = direction; |
---|
29 | this.ntriples = ntriples; |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | public LabeledMultiDigraph(){ |
---|
34 | adjlist = new ArrayList<List<LabeledEdge>>(); |
---|
35 | labels = new LinkedList<String>(); |
---|
36 | labelednodes = new HashMap<String, Integer>(); |
---|
37 | } |
---|
38 | |
---|
39 | public void addNode(String label){ |
---|
40 | labelednodes.put(label, labels.size()); |
---|
41 | labels.add(label); |
---|
42 | adjlist.add(new LinkedList<LabeledEdge>()); |
---|
43 | } |
---|
44 | |
---|
45 | public void addEdge(Integer node1, Integer node2, String elabel, Direction direction, Integer ntriples){ |
---|
46 | if ( labels.size() < node1 || labels.size() < node2 ){ |
---|
47 | System.err.println("Error for Edge Addition: No Node for the Edge"); |
---|
48 | return; |
---|
49 | } |
---|
50 | LabeledEdge edge = new LabeledEdge(node2, elabel, direction, ntriples); |
---|
51 | adjlist.get(node1).add(edge); |
---|
52 | } |
---|
53 | } |
---|