本文整理汇总了Java中org.neo4j.graphdb.Node.getSingleRelationship方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getSingleRelationship方法的具体用法?Java Node.getSingleRelationship怎么用?Java Node.getSingleRelationship使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.graphdb.Node
的用法示例。
在下文中一共展示了Node.getSingleRelationship方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: alternatingOrder
import org.neo4j.graphdb.Node; //导入方法依赖的package包/类
static ArrayList<Node> alternatingOrder (Node order) {
ArrayList<Node> products = new ArrayList<>();
Relationship prevRel = order.getSingleRelationship(RelationshipTypes.PREV, Direction.OUTGOING);
if (prevRel != null) {
Node prevOrder = prevRel.getEndNode();
prevRel = prevOrder.getSingleRelationship(RelationshipTypes.PREV, Direction.OUTGOING);
if (prevRel != null) {
prevOrder = prevRel.getEndNode();
for (Relationship r1 : prevOrder.getRelationships(Direction.OUTGOING, RelationshipTypes.HAS)) {
Node product = r1.getEndNode();
products.add(product);
}
}
}
return products;
}
示例2: repeatLastOrder
import org.neo4j.graphdb.Node; //导入方法依赖的package包/类
static ArrayList<Node> repeatLastOrder (Node order) {
ArrayList<Node> products = new ArrayList<>();
Relationship prevRel = order.getSingleRelationship(RelationshipTypes.PREV, Direction.OUTGOING);
if (prevRel != null) {
Node prevOrder = prevRel.getEndNode();
for (Relationship r1 : prevOrder.getRelationships(Direction.OUTGOING, RelationshipTypes.HAS)) {
Node product = r1.getEndNode();
products.add(product);
}
}
return products;
}
示例3: topReorderedBoostedByCartOrder
import org.neo4j.graphdb.Node; //导入方法依赖的package包/类
static ArrayList<Node> topReorderedBoostedByCartOrder(Node order) {
ArrayList<Integer> sizes = new ArrayList<>();
HashMap<Node, Double> products = new HashMap<>();
Relationship ordered = order.getSingleRelationship(RelationshipTypes.ORDERED_BY, Direction.OUTGOING);
Node user = ordered.getEndNode();
for (Relationship r1 : user.getRelationships(Direction.INCOMING, RelationshipTypes.ORDERED_BY)) {
Node prevOrder = r1.getStartNode();
sizes.add(prevOrder.getDegree(RelationshipTypes.HAS, Direction.OUTGOING));
for (Relationship r2 : prevOrder.getRelationships(Direction.OUTGOING, RelationshipTypes.HAS)) {
Node product = r2.getEndNode();
Double count = 1.0;
Double boost = 0.0;
// Products added to the cart earlier are more likely to be re-ordered, give them a boost
switch (String.valueOf(r2.getProperty("order",99))){
case "1" : boost = 0.3; break;
case "2" : boost = 0.2; break;
case "3" : boost = 0.1; break;
}
if (products.containsKey(product)) {
count = 1.0 + products.get(product);
}
products.put(product, count + boost);
}
}
Long average = Math.round(sizes.stream().mapToInt(i -> i).average().orElse(0));
List<Node> topProducts = products.entrySet().stream()
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
.limit(average)
.map(Map.Entry::getKey)
.collect(Collectors.toList());
return (ArrayList<Node>) topProducts;
}