/** * Returns a collection of all logical graph contained in the database. * * @return collection of all logical graphs */ public GraphCollection getGraphCollection() { ExecutionEnvironment env = config.getExecutionEnvironment(); DataSet<Vertex> newVertices = env.fromCollection(getVertices()) .filter(vertex -> vertex.getGraphCount() > 0); DataSet<Edge> newEdges = env.fromCollection(getEdges()) .filter(edge -> edge.getGraphCount() > 0); return config.getGraphCollectionFactory() .fromDataSets(env.fromCollection(getGraphHeads()), newVertices, newEdges); }
/** * Returns a collection of all logical graph contained in the database. * * @return collection of all logical graphs */ public GraphCollection getGraphCollection() { ExecutionEnvironment env = config.getExecutionEnvironment(); DataSet<Vertex> newVertices = env.fromCollection(getVertices()) .filter(vertex -> vertex.getGraphCount() > 0); DataSet<Edge> newEdges = env.fromCollection(getEdges()) .filter(edge -> edge.getGraphCount() > 0); return config.getGraphCollectionFactory() .fromDataSets(env.fromCollection(getGraphHeads()), newVertices, newEdges); }
@Test public void testAppendFromStringWithVariables() { AsciiGraphLoader<GraphHead, Vertex, Edge> asciiGraphLoader = AsciiGraphLoader.fromString("g0[(a)-[e]->(b)]", config); validateCollections(asciiGraphLoader, 1, 2, 1); validateCaches(asciiGraphLoader, 1, 2, 1); asciiGraphLoader.appendFromString("g1[(a)-[e]->(b)]"); validateCollections(asciiGraphLoader, 2, 2, 1); validateCaches(asciiGraphLoader, 2, 2, 1); GraphHead g1 = asciiGraphLoader.getGraphHeadByVariable("g0"); GraphHead g2 = asciiGraphLoader.getGraphHeadByVariable("g1"); Vertex a = asciiGraphLoader.getVertexByVariable("a"); Edge e = asciiGraphLoader.getEdgeByVariable("e"); assertEquals("Vertex has wrong graph count", 2, a.getGraphCount()); assertTrue("Vertex was not in g1", a.getGraphIds().contains(g1.getId())); assertTrue("Vertex was not in g2", a.getGraphIds().contains(g2.getId())); assertEquals("Edge has wrong graph count", 2, e.getGraphCount()); assertTrue("Edge was not in g1", a.getGraphIds().contains(g1.getId())); assertTrue("Edge was not in g2", a.getGraphIds().contains(g2.getId())); }