Graphs { @Description("apoc.graph.fromCypher('kernelTransaction',{params},'name',{properties}) - creates a virtual graph object for later processing") @Procedure public Stream<VirtualGraph> fromCypher(@Name("kernelTransaction") String statement, @Name("params") Map<String,Object> params,@Name("name") String name, @Name("properties") Map<String,Object> properties) { params = params == null ? Collections.emptyMap() : params; Set<Node> nodes = new HashSet<>(1000); Set<Relationship> rels = new HashSet<>(1000); Map<String,Object> props = new HashMap<>(properties); tx.execute(Cypher.withParamMapping(statement, params.keySet()), params).stream().forEach(row -> { row.forEach((k,v) -> { if (!extract(v,nodes,rels)) { props.put(k,v); } }); }); return Stream.of(new VirtualGraph(name,nodes,rels,props)); }  @Description("apoc.graph.fromData([nodes],[relationships],'name',{properties}) | creates a virtual graph object for later processing") @Procedure Stream<VirtualGraph> fromData(@Name("nodes") List<Node> nodes, @Name("relationships") List<Relationship> relationships, @Name("name") String name, @Name("properties") Map<String,Object> properties); @Description("apoc.graph.from(data,'name',{properties}) | creates a virtual graph object for later processing it tries its best to extract the graph information from the data you pass in") @Procedure Stream<VirtualGraph> from(@Name("data") Object data, @Name("name") String name, @Name("properties") Map<String,Object> properties); static boolean extract(Object data, Set<Node> nodes, Set<Relationship> rels); @Description("apoc.graph.fromPaths(path,'name',{properties}) - creates a virtual graph object for later processing") @Procedure Stream<VirtualGraph> fromPath(@Name("path") Path paths, @Name("name") String name, @Name("properties") Map<String,Object> properties); @Description("apoc.graph.fromPaths([paths],'name',{properties}) - creates a virtual graph object for later processing") @Procedure Stream<VirtualGraph> fromPaths(@Name("paths") List<Path> paths, @Name("name") String name, @Name("properties") Map<String,Object> properties); @Description("apoc.graph.fromDB('name',{properties}) - creates a virtual graph object for later processing") @Procedure Stream<VirtualGraph> fromDB(@Name("name") String name, @Name("properties") Map<String,Object> properties); @Description("apoc.graph.fromCypher('kernelTransaction',{params},'name',{properties}) - creates a virtual graph object for later processing") @Procedure Stream<VirtualGraph> fromCypher(@Name("kernelTransaction") String statement,  @Name("params") Map<String,Object> params,@Name("name") String name,  @Name("properties") Map<String,Object> properties); @Description("apoc.graph.fromDocument({json}, {config}) yield graph - transform JSON documents into graph structures") @Procedure(mode = Mode.WRITE) Stream<VirtualGraph> fromDocument(@Name("json") Object document, @Name(value = "config", defaultValue = "{}") Map<String,Object> config); @Description("apoc.graph.validateDocument({json}, {config}) yield row - validates the json, return the result of the validation") @Procedure(mode = Mode.READ) Stream<RowResult> validateDocument(@Name("json") Object document, @Name(value = "config", defaultValue = "{}") Map<String,Object> config); @Context
    public Transaction tx; }
@Test public void testFromCypher() throws Exception { TestUtil.testCall(db,"CALL apoc.graph.fromCypher('MATCH (n)-[r]->(m) RETURN *',null,'test',{answer:42}) YIELD graph RETURN *", r -> assertEquals(graph, r.get("graph"))); }