@Override public boolean evaluate(Graph graph, Edge edge) { return type.equals(edge.getType()); }
@Override public boolean addEdge(final Edge edge) { autoWriteLock(); try { int type = edge.getType(); if (edgeTypeStore != null && !edgeTypeStore.contains(type)) { if (GraphStoreConfiguration.ENABLE_AUTO_TYPE_REGISTRATION) { edgeTypeStore.addType(String.valueOf(type), type); } else { throw new RuntimeException("The type doesn't exist"); } } return edgeStore.add(edge); } finally { autoWriteUnlock(); } }
@Override public boolean addEdge(final Edge edge) { autoWriteLock(); try { int type = edge.getType(); if (edgeTypeStore != null && !edgeTypeStore.contains(type)) { if (GraphStoreConfiguration.ENABLE_AUTO_TYPE_REGISTRATION) { edgeTypeStore.addType(String.valueOf(type), type); } else { throw new RuntimeException("The type doesn't exist"); } } return edgeStore.add(edge); } finally { autoWriteUnlock(); } }
@Override public Graph filter(Subgraph[] graphs) { if (graphs.length > 1) { throw new IllegalArgumentException("Not Filter accepts a single graph in parameter"); } Graph graph = graphs[0]; Graph mainGraph = graph.getView().getGraphModel().getGraph(); for (Edge e : mainGraph.getEdges()) { Node source = e.getSource(); Node target = e.getTarget(); if (graph.contains(source) && graph.contains(target)) { Edge edgeInGraph = graph.getEdge(source, target, e.getType()); if (edgeInGraph == null) { //The edge is not in graph graph.addEdge(e); } else { //The edge is in the graph graph.removeEdge(edgeInGraph); } } } return graph; }
@Override public Graph filter(Subgraph[] graphs) { if (graphs.length > 1) { throw new IllegalArgumentException("Not Filter accepts a single graph in parameter"); } Graph graph = graphs[0]; Graph mainGraph = graph.getView().getGraphModel().getGraph(); for (Node n : mainGraph.getNodes().toArray()) { if (!graph.contains(n)) { //The node n is not in graph graph.addNode(n); } else { //The node n is in graph graph.removeNode(n); } } for (Edge e : mainGraph.getEdges()) { Node source = e.getSource(); Node target = e.getTarget(); if (graph.contains(source) && graph.contains(target)) { Edge edgeInGraph = graph.getEdge(source, target, e.getType()); if (edgeInGraph == null) { graph.addEdge(e); } } } return graph; }