public Set<Integer> getNeighborsIds(int nodeId) { Set<Integer> neighbours = new HashSet<Integer>(); try (Transaction tx = neo4jGraph.beginTx()) { Node n = nodeIndex.get("nodeId", nodeId).getSingle(); for(Relationship relationship : n.getRelationships(Direction.OUTGOING)) { Node neighbour = relationship.getEndNode(); String neighbourId = (String)neighbour.getProperty("nodeId"); neighbours.add(Integer.valueOf(neighbourId)); } tx.success(); tx.close(); } return neighbours; }System.out.println(IteratorUtil.count(n.getRelationships(Direction.OUTGOING)));
--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Which version of Neo4j are you using?
You use a Set which elminates duplicates. You probably have duplicate neighbourId's that are only 100 distinct ones.
You received this message because you are subscribed to a topic in the Google Groups "Neo4j" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/neo4j/stHamJpQSBk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to neo4j+un...@googlegroups.com.
public void createGraphForMassiveLoad(String dbPath) { System.out.println("Creating Neo4j Graph Database for massive load . . . ."); Map<String, String> config = new HashMap<String, String>(); config.put("cache_type", "none"); config.put("use_memory_mapped_buffers", "true"); config.put("neostore.nodestore.db.mapped_memory", "200M"); config.put("neostore.relationshipstore.db.mapped_memory", "1000M"); config.put("neostore.propertystore.db.mapped_memory", "250M"); config.put("neostore.propertystore.db.strings.mapped_memory", "250M"); inserter = BatchInserters.inserter(dbPath, config); indexProvider = new LuceneBatchInserterIndexProvider(inserter); nodes = indexProvider.nodeIndex("nodes", MapUtil.stringMap("type", "exact")); }public void createGraph(String datasetDir) { System.out.println("Loading data in massive mode in Neo4j database . . . ."); inserter.createDeferredSchemaIndex(Neo4jGraphDatabase.NODE_LABEL).on("nodeId").create(); try { BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(datasetDir))); String line; int lineCounter = 1;// Map<String, Object> properties;// IndexHits<Long> cache; long srcNode, dstNode; while((line = reader.readLine()) != null) { if(lineCounter > 4) { String[] parts = line.split("\t"); srcNode = getOrCreate(parts[0]); dstNode = getOrCreate(parts[1]); inserter.createRelationship(srcNode, dstNode, Neo4jGraphDatabase.RelTypes.SIMILAR, null); } lineCounter++; } reader.close(); } catch (IOException e) { e.printStackTrace(); } nodes.flush(); } private long getOrCreate(String value) { Long id = cache.get(Long.valueOf(value)); if(id == null) { Map<String, Object> properties = MapUtil.map("nodeId", value); id = inserter.createNode(properties, Neo4jGraphDatabase.NODE_LABEL); cache.put(Long.valueOf(value), id); nodes.add(id, properties); } return id; }