use of apoc.result.VirtualGraph in project neo4j-apoc-procedures by neo4j-contrib.
the class Graphs method fromCypher.
@Description("apoc.graph.fromCypher('statement',{params},'name',{properties}) - creates a virtual graph object for later processing")
@Procedure
public Stream<VirtualGraph> fromCypher(@Name("statement") 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);
db.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));
}
use of apoc.result.VirtualGraph in project neo4j-apoc-procedures by neo4j-contrib.
the class Graphs method fromPaths.
@Description("apoc.graph.fromPaths([paths],'name',{properties}) - creates a virtual graph object for later processing")
@Procedure
public Stream<VirtualGraph> fromPaths(@Name("paths") List<Path> paths, @Name("name") String name, @Name("properties") Map<String, Object> properties) {
List<Node> nodes = new ArrayList<>(1000);
List<Relationship> rels = new ArrayList<>(1000);
for (Path path : paths) {
Iterables.addAll(nodes, path.nodes());
Iterables.addAll(rels, path.relationships());
}
return Stream.of(new VirtualGraph(name, nodes, rels, properties));
}
use of apoc.result.VirtualGraph in project neo4j-apoc-procedures by neo4j-contrib.
the class Graphs method from.
@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
public Stream<VirtualGraph> from(@Name("data") Object data, @Name("name") String name, @Name("properties") Map<String, Object> properties) {
Set<Node> nodes = new HashSet<>(1000);
Set<Relationship> rels = new HashSet<>(10000);
extract(data, nodes, rels);
return Stream.of(new VirtualGraph(name, nodes, rels, properties));
}
Aggregations