diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-08-01 18:53:23 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-08-01 18:53:23 +0100 |
| commit | 3d1c8553f61747b54a8304a39f401f9b77f8cf57 (patch) | |
| tree | 1e1374da8ae640b7e5c4aff86a5ab2d8d413f2ac /src/uk/ac/ox/cs/pagoda/util/data_structures | |
| parent | 3d44aee6069175038266c65f945147569e6343f6 (diff) | |
| download | ACQuA-3d1c8553f61747b54a8304a39f401f9b77f8cf57.tar.gz ACQuA-3d1c8553f61747b54a8304a39f401f9b77f8cf57.zip | |
Option for SkolemUpperBound application and for skolemisation depth (from file pagoda.properties).
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/util/data_structures')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/util/data_structures/Graph.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/util/data_structures/Graph.java b/src/uk/ac/ox/cs/pagoda/util/data_structures/Graph.java new file mode 100644 index 0000000..4f454df --- /dev/null +++ b/src/uk/ac/ox/cs/pagoda/util/data_structures/Graph.java | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.util.data_structures; | ||
| 2 | |||
| 3 | import java.util.*; | ||
| 4 | |||
| 5 | public class Graph<V> { | ||
| 6 | |||
| 7 | private final boolean isDirected; | ||
| 8 | |||
| 9 | private Map<V, Set<V>> outEdgesOf = new HashMap<>(); | ||
| 10 | public Graph(boolean isDirected) { | ||
| 11 | this.isDirected = isDirected; | ||
| 12 | } | ||
| 13 | |||
| 14 | public Graph() { | ||
| 15 | this(false); | ||
| 16 | } | ||
| 17 | public void addNode(V v) { | ||
| 18 | if(!outEdgesOf.containsKey(v)) | ||
| 19 | outEdgesOf.put(v, new HashSet<V>()); | ||
| 20 | } | ||
| 21 | |||
| 22 | public void addEdge(V v, V u) { | ||
| 23 | addNode(v); | ||
| 24 | addNode(u); | ||
| 25 | outEdgesOf.get(v).add(u); | ||
| 26 | |||
| 27 | if(isDirected) | ||
| 28 | outEdgesOf.get(u).add(v); | ||
| 29 | } | ||
| 30 | |||
| 31 | public Iterator<V> getOutNeighbors(V v) { | ||
| 32 | return outEdgesOf.get(v).iterator(); | ||
| 33 | } | ||
| 34 | |||
| 35 | public boolean isDirected() { | ||
| 36 | return isDirected; | ||
| 37 | } | ||
| 38 | } | ||
