当前位置: 首页>>代码示例>>Java>>正文


Java Node.getRelationships方法代码示例

本文整理汇总了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;
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:20,代码来源:Traversals.java

示例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;
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:20,代码来源:Traversals.java

示例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;
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:22,代码来源:Traversals.java

示例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;
}
 
开发者ID:maxdemarzi,项目名称:instacart,代码行数:17,代码来源:Predictions.java

示例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;
}
 
开发者ID:maxdemarzi,项目名称:rule_matcher,代码行数:22,代码来源:Matcher.java

示例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;
	}
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:32,代码来源:Traversals.java

示例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 "";
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:29,代码来源:Traversals.java

示例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());
		}
	}
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:28,代码来源:DDGPatcher.java

示例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;
}
 
开发者ID:maxdemarzi,项目名称:instacart,代码行数:13,代码来源:Predictions.java

示例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;
}
 
开发者ID:maxdemarzi,项目名称:instacart,代码行数:33,代码来源:Predictions.java


注:本文中的org.neo4j.graphdb.Node.getRelationships方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。