Gephi { @Procedure @Description("apoc.gephi.add(url-or-key, workspace, data, weightproperty, ['exportproperty']) | streams passed in data to Gephi") public Stream<ProgressInfo> add(@Name("urlOrKey") String keyOrUrl, @Name("workspace") String workspace, @Name("data") Object data,@Name(value = "weightproperty",defaultValue = "null") String weightproperty,@Name(value = "exportproperties",defaultValue = "[]") List<String> exportproperties) { if (workspace == null) workspace = "workspace0"; String url = getGephiUrl(keyOrUrl)+"/"+Util.encodeUrlComponent(workspace)+"?operation=updateGraph"; long start = System.currentTimeMillis(); HashSet<Node> nodes = new HashSet<>(1000); HashSet<Relationship> rels = new HashSet<>(10000); List<String> propertyNames = new ArrayList<>(exportproperties); propertyNames.removeAll(RESERVED); if (Graphs.extract(data, nodes, rels)) { String payload = toGephiStreaming(nodes, rels, weightproperty, propertyNames.toArray(new String[propertyNames.size()])); JsonUtil.loadJson(url,map("method","POST","Content-Type","application/json; charset=utf-8"), payload).count(); return Stream.of(new ProgressInfo(url,"graph","gephi").update(nodes.size(),rels.size(),nodes.size()).done(start)); } return Stream.empty(); }  static double doubleValue(Entity pc, String prop, Number defaultValue); @Procedure @Description("apoc.gephi.add(url-or-key, workspace, data, weightproperty, ['exportproperty']) | streams passed in data to Gephi") Stream<ProgressInfo> add(@Name("urlOrKey") String keyOrUrl, @Name("workspace") String workspace, @Name("data") Object data,@Name(value = "weightproperty",defaultValue = "null") String weightproperty,@Name(value = "exportproperties",defaultValue = "[]") List<String> exportproperties); static final int WIDTH; static final int HEIGHT; }
@Test public void testAdd() throws Exception { testCall(db, "MATCH p = (:Foo)-->() WITH p CALL apoc.gephi.add(null,$workspace,p) yield nodes, relationships, format return *", map("workspace", GEPHI_WORKSPACE), r -> { assertEquals(2L, r.get("nodes")); assertEquals(1L, r.get("relationships")); assertEquals("gephi", r.get("format")); }); }