本文整理汇总了Java中org.neo4j.helpers.collection.Iterables.count方法的典型用法代码示例。如果您正苦于以下问题:Java Iterables.count方法的具体用法?Java Iterables.count怎么用?Java Iterables.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.helpers.collection.Iterables
的用法示例。
在下文中一共展示了Iterables.count方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertTree
import org.neo4j.helpers.collection.Iterables; //导入方法依赖的package包/类
private void assertTree(String filename) throws IOException {
System.out.println("assert tree from " + filename);
NubTree expected = NubTree.read("trees/" + filename);
// compare trees
assertEquals("Number of roots differ", expected.getRoot().children.size(), Iterators.count(dao.allRootTaxa()));
TreeAsserter treeAssert = new TreeAsserter(expected);
TreeWalker.walkTree(dao.getNeo(), true, treeAssert);
assertTrue("There should be more taxa", treeAssert.completed());
// verify all nodes are walked in the tree and contains the expected numbers
long neoCnt = Iterables.count(dao.getNeo().getAllNodes());
// pro parte nodes are counted multiple times, so expected count can be higher than pure number of nodes - but never less!
System.out.println("expected nodes: " + expected.getCount());
System.out.println("counted nodes: " + neoCnt);
assertTrue(expected.getCount() >= neoCnt);
}
示例2: resetPropertiesValues
import org.neo4j.helpers.collection.Iterables; //导入方法依赖的package包/类
public void resetPropertiesValues() {
long nodesCount = 0;
if (graph != null) {
nodesCount = Iterables.count(GlobalGraphOperations.at(graph).getAllNodes());
}
// Tuning
if (nodesCount >= 100) {
setScalingRatio(2.0);
} else {
setScalingRatio(10.0);
}
setStrongGravityMode(false);
setGravity(1.);
// Behavior
setOutboundAttractionDistribution(false);
setLinLogMode(false);
setAdjustSizes(false);
setEdgeWeightInfluence(1.);
// Performance
if (nodesCount >= 50000) {
setJitterTolerance(10d);
} else if (nodesCount >= 5000) {
setJitterTolerance(1d);
} else {
setJitterTolerance(0.1d);
}
if (nodesCount >= 1000) {
setBarnesHutOptimize(true);
} else {
setBarnesHutOptimize(false);
}
setBarnesHutTheta(1.2);
setThreadsCount(2);
}
示例3: getDegree
import org.neo4j.helpers.collection.Iterables; //导入方法依赖的package包/类
@Override
public int getDegree(RelationshipType relationshipType) {
return (int) Iterables.count(getRelationships(relationshipType));
}
示例4: calculate
import org.neo4j.helpers.collection.Iterables; //导入方法依赖的package包/类
/***
* Performs one iteration of the pageRank algorithm.
*
* @param nodeLabel The label for which the algorithm needs to be calcualted
* @param relationship The relationship to use to check if the nodes are related or not
* @param property The property to update with the new pagerank
*/
@Procedure("pagerank.calculate")
@PerformsWrites
public void calculate( @Name("nodeLabel") String nodeLabel,
@Name("relationship") String relationship,
@Name("property") String property )
{
Label label = Label.label(nodeLabel);
RelationshipType relationshipType = RelationshipType.withName(relationship);
try (ResourceIterator<Node> nodes = db.findNodes(label)) {
while (nodes.hasNext()) {
Node destination = nodes.next();
Iterable<Relationship> relationships = destination.getRelationships(Direction.INCOMING, relationshipType);
double points = 0;
for (Relationship r : relationships) {
Node source = r.getStartNode();
if (!source.hasLabel(label)) {
continue;
}
if (source.equals(destination)) {
continue;
}
// TODO: this will calculate relations which hav an outgoing link to a node that doesn't have the
// needed label as well, but checking this might make the code less performant
// it will also calculate relations which go back to the original node, which also skews the result
long sourceRelationshipCount = Iterables.count(source.getRelationships(Direction.OUTGOING, relationshipType));
if (source.hasProperty(property) && source.getProperty(property) instanceof Double) {
points += (Double)source.getProperty(property) / sourceRelationshipCount;
}
}
destination.setProperty(property, PAGE_RANK_DAMPING + (1-PAGE_RANK_DAMPING)*points);
}
}
}
示例5: countDescendants
import org.neo4j.helpers.collection.Iterables; //导入方法依赖的package包/类
private long countDescendants(NubUsage u) {
return Iterables.count(Traversals.DESCENDANTS.traverse(u.node).nodes());
}
示例6: countAll
import org.neo4j.helpers.collection.Iterables; //导入方法依赖的package包/类
private long countAll() {
try (Transaction tx = db.beginTx()) {
return Iterables.count(db.getAllNodes());
}
}
示例7: getStats
import org.neo4j.helpers.collection.Iterables; //导入方法依赖的package包/类
public NormalizerStats getStats() {
int roots = 0;
int depth = -1;
int synonyms = 0;
int ignored = 0;
Map<Origin, Integer> countByOrigin = Maps.newHashMap();
Map<Rank, Integer> countByRank = Maps.newHashMap();
for (Node n : dao.getNeo().getAllNodes()) {
if (!n.hasLabel(Labels.TAXON)) {
ignored++;
continue;
}
NameUsage u = dao.readUsage(n, false);
if (n.hasLabel(Labels.ROOT)) {
roots++;
}
// pro parte relations count as extra synonyms!
final int countAs = n.hasLabel(Labels.SYNONYM) ? (int) Iterables.count(Traversals.ACCEPTED.traverse(n).nodes()) : 1;
if (n.hasLabel(Labels.SYNONYM)) {
synonyms = synonyms + countAs;
if (!n.hasRelationship(RelType.SYNONYM_OF)) {
throw new IllegalStateException("Node "+n.getId()+" with synonym label but without synonymOf relationship found");
}
} else if (u.isSynonym()) {
throw new IllegalStateException("Node "+n.getId()+" without synonym label but usage has isSynonym=true");
}
if (!countByOrigin.containsKey(u.getOrigin())) {
countByOrigin.put(u.getOrigin(), countAs);
} else {
countByOrigin.put(u.getOrigin(), countByOrigin.get(u.getOrigin()) + countAs);
}
if (u.getRank() != null) {
if (!countByRank.containsKey(u.getRank())) {
countByRank.put(u.getRank(), countAs);
} else {
countByRank.put(u.getRank(), countByRank.get(u.getRank()) + countAs);
}
}
}
return new NormalizerStats(roots, depth, synonyms, ignored, countByOrigin, countByRank, Lists.<String>newArrayList());
}