本文整理汇总了Java中org.neo4j.graphdb.Node.getRelationships方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getRelationships方法的具体用法?Java Node.getRelationships怎么用?Java Node.getRelationships使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.graphdb.Node
的用法示例。
在下文中一共展示了Node.getRelationships方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChildrenConnectedBy
import org.neo4j.graphdb.Node; //导入方法依赖的package包/类
public static List<Node> getChildrenConnectedBy(Node node, String edgeType)
{
List<Node> retval = new LinkedList<Node>();
long nodeId = node.getId();
Iterable<Relationship> rels = node.getRelationships();
for (Relationship rel : rels)
{
if (!rel.getType().name().equals(edgeType))
continue;
Node childNode = rel.getEndNode();
if (childNode.getId() == nodeId)
continue;
retval.add(childNode);
}
return retval;
}
示例2: getParentsConnectedBy
import org.neo4j.graphdb.Node; //导入方法依赖的package包/类
public static List<Node> getParentsConnectedBy(Node node, String edgeType)
{
List<Node> retval = new LinkedList<Node>();
long nodeId = node.getId();
Iterable<Relationship> rels = node.getRelationships();
for (Relationship rel : rels)
{
if (!rel.getType().name().equals(edgeType))
continue;
Node parentNode = rel.getStartNode();
if (parentNode.getId() == nodeId)
continue;
retval.add(parentNode);
}
return retval;
}
示例3: getDDGForFunction
import org.neo4j.graphdb.Node; //导入方法依赖的package包/类
public static DDG getDDGForFunction(Node funcNode)
{
DDG retval = new DDG();
for (Node statement : Traversals.getStatementsForFunction(funcNode))
{
Iterable<Relationship> rels = statement
.getRelationships(Direction.OUTGOING);
long srcId = statement.getId();
for (Relationship rel : rels)
{
if (!rel.getType().toString().equals(EdgeTypes.REACHES))
continue;
long dstId = rel.getEndNode().getId();
String symbol = rel.getProperty("var").toString();
retval.add(srcId, dstId, symbol);
}
}
return retval;
}
示例4: 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;
}
示例5: matchUser
import org.neo4j.graphdb.Node; //导入方法依赖的package包/类
@Procedure(name = "com.maxdemarzi.match.user", mode = Mode.READ)
@Description("CALL com.maxdemarzi.match.user(username) - find matching rules")
public Stream<NodeResult> matchUser(@Name("username") String username) throws IOException {
// We start by finding the user
Node user = db.findNode(Labels.User, "username", username);
if (user != null) {
// Gather all of their attributes in to a Set
Set<Node> userAttributes = new HashSet<>();
Collection<String> attributes = new HashSet<>();
for (Relationship r : user.getRelationships(Direction.OUTGOING, RelationshipTypes.HAS)) {
userAttributes.add(r.getEndNode());
attributes.add((String)r.getEndNode().getProperty("id"));
}
// Find the rules
Set<Node> rules = findRules(attributes, userAttributes);
return rules.stream().map(NodeResult::new);
}
return null;
}
示例6: getStatementForASTNode
import org.neo4j.graphdb.Node; //导入方法依赖的package包/类
public static Node getStatementForASTNode(Node node)
{
Node n = node;
Node parent = node;
while (true)
{
try
{
Object property = n.getProperty(NodeKeys.IS_CFG_NODE);
return n;
}
catch (NotFoundException ex)
{
}
Iterable<Relationship> rels = n
.getRelationships(Direction.INCOMING);
for (Relationship rel : rels)
{
parent = rel.getStartNode();
break;
}
if (n == parent)
return null;
n = parent;
}
}
示例7: getCalleeFromCall
import org.neo4j.graphdb.Node; //导入方法依赖的package包/类
public static String getCalleeFromCall(Long nodeId)
{
Node node = Neo4JDBInterface.getNodeById(nodeId);
Iterable<Relationship> rels = node.getRelationships();
for (Relationship rel : rels)
{
if (!rel.getType().name().equals(EdgeTypes.IS_AST_PARENT))
continue;
Node endNode = rel.getEndNode();
if (endNode.getId() == node.getId())
continue;
try
{
String childNumStr = (String) endNode
.getProperty(NodeKeys.CHILD_NUMBER);
if (childNumStr.equals("0"))
return endNode.getProperty(NodeKeys.CODE).toString();
}
catch (RuntimeException ex)
{
return endNode.getProperty(NodeKeys.CODE).toString();
}
}
return "";
}
示例8: removeOldEdges
import org.neo4j.graphdb.Node; //导入方法依赖的package包/类
private void removeOldEdges(DDGDifference diff)
{
List<DefUseRelation> relsToRemove = diff.getRelsToRemove();
for (DefUseRelation rel : relsToRemove)
{
Node srcStatement = Neo4JDBInterface.getNodeById((Long) rel.src);
Iterable<Relationship> rels = srcStatement
.getRelationships(Direction.OUTGOING);
for (Relationship reachRel : rels)
{
if (!reachRel.getType().name().equals(EdgeTypes.REACHES))
continue;
if (reachRel.getEndNode().getId() != (Long) rel.dst)
continue;
Object var = reachRel.getProperty("var");
if (var == null || !var.toString().equals(rel.symbol))
continue;
Neo4JDBInterface.removeEdge(reachRel.getId());
}
}
}
示例9: 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;
}
示例10: 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;
}