GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — RepGraph/src/main/java/com/RepGraph/Node.java at main · RepGraph/RepGraph Expand file tree/ Copy pathNode.javaMore file actions 283 lines (220 loc) · 6.92 KB / Copy pathNode.javaFile metadata and controls283 lines (220 loc) · 6.92 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 /** * A semantic Node class that represents a Node in a Graph. * * @since 29/08/2020 */ package com.RepGraph; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.type.MapType; import com.fasterxml.jackson.databind.type.TypeFactory; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; /** * Node object - contains node information */ @JsonIgnoreProperties(ignoreUnknown = true) public class Node { @JsonProperty("id") private String id; @JsonProperty("label") private String label; @JsonProperty("anchors") private ArrayList<Anchors> anchors; @JsonProperty("properties") private ArrayList<String> properties; @JsonProperty("values") private ArrayList<String> values; @JsonProperty("surface") private boolean surface; @JsonProperty("dummy") private boolean dummy = false; @JsonIgnore private ArrayList<Anchors> characterSpans; @JsonIgnore private ArrayList<Node> directedNeighbours; @JsonIgnore private ArrayList<Node> undirectedNeighbours; @JsonIgnore private ArrayList<Edge> directedEdgeNeighbours; @JsonIgnore private ArrayList<Edge> undirectedEdgeNeighbours; public Node() { this.directedNeighbours = new ArrayList<>(); this.undirectedNeighbours = new ArrayList<>(); this.directedEdgeNeighbours = new ArrayList<>(); this.undirectedEdgeNeighbours = new ArrayList<>(); } /** * Fully parameterised constructor for the Node class. * @param id The Node's ID number. * @param label The Node's label. * @param anchors An array list of the Node's Anchors. */ public Node(String id, String label, ArrayList<Anchors> anchors) { this.id = id; this.label = label; this.anchors = anchors; this.undirectedNeighbours = new ArrayList<>(); this.directedNeighbours = new ArrayList<>(); this.directedEdgeNeighbours = new ArrayList<>(); this.undirectedEdgeNeighbours = new ArrayList<>(); } /** * Copy constructor for the Node class. * The copy constructor does not copy across neighbouring nodes or neighbouring edges * as it is unnecessary and should only be populated if necessary for analysis * * @param n This is the Node that is being copied. */ public Node(Node n) { this.label = n.label; this.id = n.id; ArrayList<Anchors> anch = null; if (n.getAnchors()!=null) { anch = new ArrayList<Anchors>(); for (Anchors anchor : n.getAnchors()) { anch.add(new Anchors(anchor.getFrom(), anchor.getEnd())); } } this.anchors = anch; this.undirectedEdgeNeighbours = new ArrayList<>(); this.directedEdgeNeighbours = new ArrayList<>(); this.directedNeighbours = new ArrayList<>(); this.undirectedNeighbours = new ArrayList<>(); this.surface = n.surface; } /** * Getter method for the Node's ID number. * @return Integer The Node's ID number. */ public String getId() { return id; } public void setId(String id) { this.id = id; } public void setCharacterSpans(ArrayList<Anchors> characterSpans) { this.characterSpans = characterSpans; } public ArrayList<Anchors> getCharacterSpans() { return characterSpans; } public String getLabel() { return label; } public void setLabel(String label) { this.label = label; } public ArrayList<Anchors> getAnchors() { return anchors; } public void setAnchors(ArrayList<Anchors> anchors) { this.anchors = anchors; } public ArrayList<String> getProperties() { return properties; } public ArrayList<String> getValues() { return values; } public void setProperties(ArrayList<String> properties) { this.properties = properties; } public void setValues(ArrayList<String> values) { this.values = values; } public boolean isSurface() { return surface; } @JsonIgnore public void setSurface(boolean surface) { this.surface = surface; } /** * Adds a directed neighbouring Node. i.e a Node that this Node points to. * @param neighbour A direct neighbouring Node. */ public void addDirectedNeighbour(Node neighbour) { directedNeighbours.add(neighbour); } /** * Adds an undirected neighbouring Node. i.e a Node that points to this Node. * @param neighbour An undirected neighbouring Node. */ public void addUndirectedNeighbour(Node neighbour) { undirectedNeighbours.add(neighbour); } /** * Getter method for a Node's directed neighbours. * @return ArrayList The Node's direct neighbours. */ public ArrayList<Node> getDirectedNeighbours() { return directedNeighbours; } /** * Getter method for a Node's undirected neighbours. * @return ArrayList The Node's undirected neighbours. */ public ArrayList<Node> getUndirectedNeighbours() { return undirectedNeighbours; } /** * Getter method for DirectedEdgeNeighbours. * * @return ArrayList A list of the edges connected from this Node to other nodes. */ public ArrayList<Edge> getDirectedEdgeNeighbours() { return directedEdgeNeighbours; } /** * Adds an Edge to the DirectedEdgeNeighbours ArrayList * * @param e This is the Edge that will be added to the DirectedEdgeNeighbours ArrayList */ public void addDirectedEdgeNeighbour(Edge e) { directedEdgeNeighbours.add(e); } /** * Getter method for UndirectedEdgeNeighbours. * * @return ArrayList A List of the edges that connect from other nodes to this Node */ public ArrayList<Edge> getUndirectedEdgeNeighbours() { return undirectedEdgeNeighbours; } /** * Adds an Edge to the UndirectedEdgeNeighbours ArrayList * * @param e This is the Edge that will be added to the UndirectedEdgeNeighbours ArrayList */ public void addUndirectedEdgeNeighbour(Edge e) { undirectedEdgeNeighbours.add(e); } /** * Equals method for the Node class. * * @param o Object * @return boolean Whether to two classes being compared are equal. */ @Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof Node)) { return false; } Node n = (Node) o; return ((id == n.getId()) && (label.equals(n.getLabel())) && (anchors.equals(n.getAnchors()))); } public boolean isDummy() { return dummy; } public void setDummy(boolean dummy) { this.dummy = dummy; } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |