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


Java Relationship.getEndNode方法代码示例

本文整理汇总了Java中org.neo4j.graphdb.Relationship.getEndNode方法的典型用法代码示例。如果您正苦于以下问题:Java Relationship.getEndNode方法的具体用法?Java Relationship.getEndNode怎么用?Java Relationship.getEndNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.neo4j.graphdb.Relationship的用法示例。


在下文中一共展示了Relationship.getEndNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getChildrenConnectedBy

import org.neo4j.graphdb.Relationship; //导入方法依赖的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: alternatingOrder

import org.neo4j.graphdb.Relationship; //导入方法依赖的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

示例3: rankDest

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
/**
 * Rank the destination nodes of the outgoing edges of the given node.
 * @param n the source node of the destination nodes to be ranked.
 */
private void rankDest(Node n) {
	int baseSource = (int) n.getProperty(BASE_DIST.name())
			+ (int) n.getProperty(Scores.SEQ_LENGTH.name());
	int rankSource = (int) n.getProperty(RANK.name()) + 1;

	for (Relationship r : n.getRelationships(RelTypes.NEXT, Direction.OUTGOING)) {
		Node dest = r.getEndNode();

		if ((int) dest.getProperty(BASE_DIST.name()) < baseSource) {
			dest.setProperty(BASE_DIST.name(), baseSource);
		}
		if ((int) dest.getProperty(RANK.name()) < rankSource) {
			dest.setProperty(RANK.name(), rankSource);
		}
	}
}
 
开发者ID:ProgrammingLife2015,项目名称:dnainator,代码行数:21,代码来源:AnalyzeCommand.java

示例4: evaluate

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public Collection<Neo4jSemaphoreNeighborInjectMatch> evaluate() {
	final Collection<Neo4jSemaphoreNeighborInjectMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (Transaction tx = graphDb.beginTx()) {
		// (route:Route)
		final Iterable<Node> routes = () -> graphDb.findNodes(Neo4jConstants.labelRoute);
		for (final Node route : routes) {
			Iterable<Relationship> entries = route.getRelationships(Direction.OUTGOING, Neo4jConstants.relationshipTypeEntry);

			for (Relationship entry : entries) {
				final Node semaphore = entry.getEndNode();

				final Map<String, Object> match = new HashMap<>();
				match.put(QueryConstants.VAR_ROUTE, route);
				match.put(QueryConstants.VAR_SEMAPHORE, semaphore);
				matches.add(new Neo4jSemaphoreNeighborInjectMatch(match));
			}
		}
	}

	return matches;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:25,代码来源:Neo4JApiQuerySemaphoreNeighborInject.java

示例5: getAdjacentNodes

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
public static Iterable<Node> getAdjacentNodes(final Node sourceNode, final RelationshipType relationshipType, final Direction direction, final Label targetNodeLabel) {
	final Collection<Node> nodes = new ArrayList<>();
	
	final Iterable<Relationship> relationships = sourceNode.getRelationships(relationshipType, direction);
	for (final Relationship relationship : relationships) {
		final Node candidate;
		switch (direction) {
		case INCOMING:
			candidate = relationship.getStartNode();
			break;
		case OUTGOING:
			candidate = relationship.getEndNode();			
			break;
		default:
			throw new UnsupportedOperationException("Direction: " + direction + " not supported.");
		}
		if (!candidate.hasLabel(targetNodeLabel)) {
			continue;
		}
		nodes.add(candidate);
	}
	return nodes;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:24,代码来源:Neo4jUtil.java

示例6: getCalleeFromCall

import org.neo4j.graphdb.Relationship; //导入方法依赖的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

示例7: repeatLastOrder

import org.neo4j.graphdb.Relationship; //导入方法依赖的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

示例8: topReorderedBoostedByCartOrder

import org.neo4j.graphdb.Relationship; //导入方法依赖的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

示例9: prepare

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
private void prepare() {
    List<String> entities = new ArrayList<>();
    List<String> relations = new ArrayList<>();
    List<Triple<String, String, String>> triples = new ArrayList<>();
    try (Transaction tx = db.beginTx()) {
        for (Node node : db.getAllNodes()) {
            if (!node.hasLabel(Label.label(JavaCodeExtractor.CLASS)) &&
                    !node.hasLabel(Label.label(JavaCodeExtractor.INTERFACE)) &&
                    !node.hasLabel(Label.label(JavaCodeExtractor.METHOD)) &&
                    !node.hasLabel(Label.label(JavaCodeExtractor.FIELD)))
                continue;
            entities.add("" + node.getId());
        }

        for (Relationship rel : db.getAllRelationships()) {
            Node node1 = rel.getStartNode();
            if (!node1.hasLabel(Label.label(JavaCodeExtractor.CLASS)) &&
                    !node1.hasLabel(Label.label(JavaCodeExtractor.INTERFACE)) &&
                    !node1.hasLabel(Label.label(JavaCodeExtractor.METHOD)) &&
                    !node1.hasLabel(Label.label(JavaCodeExtractor.FIELD)))
                continue;
            Node node2 = rel.getEndNode();
            if (!node2.hasLabel(Label.label(JavaCodeExtractor.CLASS)) &&
                    !node2.hasLabel(Label.label(JavaCodeExtractor.INTERFACE)) &&
                    !node2.hasLabel(Label.label(JavaCodeExtractor.METHOD)) &&
                    !node2.hasLabel(Label.label(JavaCodeExtractor.FIELD)))
                continue;
            triples.add(new ImmutableTriple<>("" + node1.getId(), "" + node2.getId(), rel.getType().name()));
            if (!relations.contains(rel.getType().name()))
                relations.add(rel.getType().name());
        }
        tx.success();
    }
    transE.prepare(entities, relations, triples);
}
 
开发者ID:linzeqipku,项目名称:SnowGraph,代码行数:36,代码来源:TransExtractor.java

示例10: getMetadataGroupKeyValueDocuments

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
protected Response getMetadataGroupKeyValueDocuments(final String group, final String key, final String value) {
	StreamingOutput stream = new StreamingOutput()
	{
		@Override
		public void write( OutputStream os ) throws IOException, WebApplicationException
		{
			try ( Transaction tx = database.beginTx() ) {
				JsonGenerator jg = objectMapper.getFactory().createGenerator(os, JsonEncoding.UTF8);
				IndexManager index = database.index();
				Index<Relationship> metadataValues = index.forRelationships("HAS_METADATUM");
				List<String> documentsSeen = new ArrayList<String>();
				jg.writeStartArray();
				
				System.out.println("VALUE: "+value);
				for (Relationship hasMetadatum : metadataValues.get("value", value)) {
					Node metadatum = hasMetadatum.getEndNode();
					String mGroup = (String) metadatum.getProperty("group");
					String mKey = (String) metadatum.getProperty("key");
					if (mGroup.equals(group) && mKey.equals(key)) {
						Node document = hasMetadatum.getStartNode();
						String xmlid = (String) document.getProperty("xmlid");
						if (!documentsSeen.contains(xmlid)) {
							jg.writeString(xmlid);
							documentsSeen.add(xmlid);
						}
					}
				}
				
				jg.writeEndArray();
				jg.flush();
				tx.success();
			}
		}
	};

	return Response.ok().entity( stream ).type( MediaType.APPLICATION_JSON ).build();
}
 
开发者ID:Taalmonsters,项目名称:WhiteLab2.0-Neo4J-Plugin,代码行数:38,代码来源:MetadatumSearcher.java

示例11: doGetForRelationships

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Test
public void doGetForRelationships()
{
    RelationshipIndex roles = graphDb.index().forRelationships( "roles" );

    // START SNIPPET: getSingleRelationship
    Relationship persephone = roles.get( "name", "Persephone" ).getSingle();
    Node actor = persephone.getStartNode();
    Node movie = persephone.getEndNode();
    // END SNIPPET: getSingleRelationship

    assertEquals( "Monica Bellucci", actor.getProperty( "name" ) );
    assertEquals( "The Matrix Reloaded", movie.getProperty( "title" ) );

    @SuppressWarnings("serial") List<String> expectedActors = new ArrayList<String>()
    {
        {
            add( "Keanu Reeves" );
            add( "Keanu Reeves" );
        }
    };
    List<String> foundActors = new ArrayList<>();

    // START SNIPPET: getRelationships
    for ( Relationship role : roles.get( "name", "Neo" ) )
    {
        // this will give us Reeves twice
        Node reeves = role.getStartNode();
        // END SNIPPET: getRelationships
        foundActors.add( (String) reeves.getProperty( "name" ) );
        // START SNIPPET: getRelationships
    }
    // END SNIPPET: getRelationships

    assertEquals( expectedActors, foundActors );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:37,代码来源:ImdbDocTest.java

示例12: compute

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public void compute(Relationship r) {
	Node n1 = r.getStartNode();
	Node n2 = r.getEndNode();
	
	if( n1.getProperty(attName) == n2.getProperty(attName) ) {
		double weight = r.hasProperty("weight") ? (double) r.getProperty("weight") : 1.0;
		eii += weight;
	}
}
 
开发者ID:besil,项目名称:Neo4jSNA,代码行数:11,代码来源:DirectedModularity.java

示例13: singleNeighborhood

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
public static Node singleNeighborhood(Node node, RelationshipTypes rel, Direction direction, boolean startNode) {
    Iterator<Relationship> it = node.getRelationships(rel, direction).iterator();
    if ( !it.hasNext() ){
        return null;
    }

    Relationship r = it.next();
    if (startNode)
        return r.getStartNode();
    return r.getEndNode();
}
 
开发者ID:vahidooo,项目名称:quranic-graph,代码行数:12,代码来源:NodeUtils.java

示例14: evaluate

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public Collection<Neo4jSwitchMonitoredMatch> evaluate() {
	final Collection<Neo4jSwitchMonitoredMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (Transaction tx = graphDb.beginTx()) {
		final Iterable<Node> sws = () -> graphDb.findNodes(Neo4jConstants.labelSwitch);
		// (sw:Switch)
		for (final Node sw : sws) {
			// (sw)-[:sensor]->(Sensor) NAC
			final Iterable<Relationship> relationshipSensors = sw.getRelationships(Direction.OUTGOING, Neo4jConstants.relationshipTypeMonitoredBy);

			boolean hasSensor = false;
			for (final Relationship relationshipSensor : relationshipSensors) {
				final Node sensor = relationshipSensor.getEndNode();
				if (sensor.hasLabel(Neo4jConstants.labelSensor)) {
					hasSensor = true;
					break;
				}
			}

			if (!hasSensor) {
				final Map<String, Object> match = new HashMap<>();
				match.put(VAR_SW, sw);
				matches.add(new Neo4jSwitchMonitoredMatch(match));
			}
		}
	}

	return matches;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:32,代码来源:Neo4JApiQuerySwitchMonitored.java

示例15: getMetadataGroupKeyValueDocumentsWithCounts

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
protected Response getMetadataGroupKeyValueDocumentsWithCounts(final String group, final String key, final String value) {
	StreamingOutput stream = new StreamingOutput()
	{
		@Override
		public void write( OutputStream os ) throws IOException, WebApplicationException
		{
			try ( Transaction tx = database.beginTx() ) {
				JsonGenerator jg = objectMapper.getFactory().createGenerator(os, JsonEncoding.UTF8);
				IndexManager index = database.index();
				Index<Relationship> metadataValues = index.forRelationships("HAS_METADATUM");
				List<String> documentsSeen = new ArrayList<String>();
				jg.writeStartArray();
				
				System.out.println("VALUE: "+value);
				for (Relationship hasMetadatum : metadataValues.get("value", value)) {
					Node metadatum = hasMetadatum.getEndNode();
					String mGroup = (String) metadatum.getProperty("group");
					String mKey = (String) metadatum.getProperty("key");
					if (mGroup.equals(group) && mKey.equals(key)) {
						Node document = hasMetadatum.getStartNode();
						String xmlid = (String) document.getProperty("xmlid");
						if (!documentsSeen.contains(xmlid)) {
							jg.writeStartObject();
							jg.writeStringField("xmlid", xmlid);
							Object tokenCount = document.getProperty("token_count");
							if (tokenCount instanceof Long)
								jg.writeNumberField("token_count", (Long) tokenCount);
							else if (tokenCount instanceof Integer)
								jg.writeNumberField("token_count", (Integer) tokenCount);
							jg.writeEndObject();
							documentsSeen.add(xmlid);
						}
					}
				}
				
				jg.writeEndArray();
				jg.flush();
				tx.success();
			}
		}
	};

	return Response.ok().entity( stream ).type( MediaType.APPLICATION_JSON ).build();
}
 
开发者ID:Taalmonsters,项目名称:WhiteLab2.0-Neo4J-Plugin,代码行数:45,代码来源:MetadatumSearcher.java


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