/** * Get the legality of a particular edge direction and label. * * @param direction the direction of the edge. * @param label the label of the edge. * @return the {@link Legal} of the arguments. */ public Legal checkEdgeLegality(final Direction direction, final String label) { if (null == this.edgeFilter) return Legal.YES; if (this.checkEdgeLegality(direction).negative()) return Legal.NO; final Map<String, Legal> legalMap = this.edgeLegality.get(direction); if (legalMap.containsKey(label)) return legalMap.get(label); else if (legalMap.containsKey(null)) return legalMap.get(null); else return Legal.NO; }
else if (graphFilter.legalVertex(this)) { if (graphFilter.hasEdgeFilter()) { if (graphFilter.checkEdgeLegality(Direction.OUT).negative()) this.dropEdges(Direction.OUT); if (graphFilter.checkEdgeLegality(Direction.IN).negative()) this.dropEdges(Direction.IN); if (null != this.outEdges) for (final String key : new HashSet<>(this.outEdges.keySet())) { if (graphFilter.checkEdgeLegality(Direction.OUT, key).negative()) this.dropEdges(Direction.OUT, key); if (graphFilter.checkEdgeLegality(Direction.IN, key).negative()) this.dropEdges(Direction.IN, key);
private <I extends InputShim> void readEdges(final KryoShim<I, ?> kryo, final I input, final StarGraph starGraph, final Direction direction) { if (kryo.readObject(input, Boolean.class)) { final int numberOfUniqueLabels = kryo.readObject(input, Integer.class); for (int i = 0; i < numberOfUniqueLabels; i++) { final String edgeLabel = kryo.readObject(input, String.class); final int numberOfEdgesWithLabel = kryo.readObject(input, Integer.class); for (int j = 0; j < numberOfEdgesWithLabel; j++) { final Object edgeId = kryo.readClassAndObject(input); final Object adjacentVertexId = kryo.readClassAndObject(input); if (this.graphFilter.checkEdgeLegality(direction, edgeLabel).positive()) { if (direction.equals(Direction.OUT)) starGraph.starVertex.addOutEdge(edgeLabel, starGraph.addVertex(T.id, adjacentVertexId), T.id, edgeId); else starGraph.starVertex.addInEdge(edgeLabel, starGraph.addVertex(T.id, adjacentVertexId), T.id, edgeId); } else if (null != starGraph.edgeProperties) { starGraph.edgeProperties.remove(edgeId); } } } } } }
/** * Get the legality of a particular edge direction and label. * * @param direction the direction of the edge. * @param label the label of the edge. * @return the {@link Legal} of the arguments. */ public Legal checkEdgeLegality(final Direction direction, final String label) { if (null == this.edgeFilter) return Legal.YES; if (this.checkEdgeLegality(direction).negative()) return Legal.NO; final Map<String, Legal> legalMap = this.edgeLegality.get(direction); if (legalMap.containsKey(label)) return legalMap.get(label); else if (legalMap.containsKey(null)) return legalMap.get(null); else return Legal.NO; }
else if (graphFilter.legalVertex(this)) { if (graphFilter.hasEdgeFilter()) { if (graphFilter.checkEdgeLegality(Direction.OUT).negative()) this.dropEdges(Direction.OUT); if (graphFilter.checkEdgeLegality(Direction.IN).negative()) this.dropEdges(Direction.IN); if (null != this.outEdges) for (final String key : new HashSet<>(this.outEdges.keySet())) { if (graphFilter.checkEdgeLegality(Direction.OUT, key).negative()) this.dropEdges(Direction.OUT, key); if (graphFilter.checkEdgeLegality(Direction.IN, key).negative()) this.dropEdges(Direction.IN, key);
private <I extends InputShim> void readEdges(final KryoShim<I, ?> kryo, final I input, final StarGraph starGraph, final Direction direction) { if (kryo.readObject(input, Boolean.class)) { final int numberOfUniqueLabels = kryo.readObject(input, Integer.class); for (int i = 0; i < numberOfUniqueLabels; i++) { final String edgeLabel = kryo.readObject(input, String.class); final int numberOfEdgesWithLabel = kryo.readObject(input, Integer.class); for (int j = 0; j < numberOfEdgesWithLabel; j++) { final Object edgeId = kryo.readClassAndObject(input); final Object adjacentVertexId = kryo.readClassAndObject(input); if (this.graphFilter.checkEdgeLegality(direction, edgeLabel).positive()) { if (direction.equals(Direction.OUT)) starGraph.starVertex.addOutEdge(edgeLabel, starGraph.addVertex(T.id, adjacentVertexId), T.id, edgeId); else starGraph.starVertex.addInEdge(edgeLabel, starGraph.addVertex(T.id, adjacentVertexId), T.id, edgeId); } else if (null != starGraph.edgeProperties) { starGraph.edgeProperties.remove(edgeId); } } } } } }