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


Java Path.length方法代码示例

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


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

示例1: minDistance

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
public static int minDistance(String cui1, String cui2){
  int distance = -1;
  try ( Transaction tx = graphDb.beginTx() ){
    Node cui1Node = graphDb.findNode(RelReader.DictLabels.Concept, RelReader.CUI_PROPERTY, cui1);
    Node cui2Node = graphDb.findNode(RelReader.DictLabels.Concept, RelReader.CUI_PROPERTY, cui2);
    if(cui1Node == null || cui2Node == null) return distance;
    
    TraversalDescription td = graphDb.traversalDescription()
        .breadthFirst()
        .relationships(RelReader.RelTypes.ISA, Direction.OUTGOING)
        .evaluator(Evaluators.excludeStartPosition())
        .evaluator(Evaluators.includeWhereEndNodeIs(cui2Node));

    Traverser traverser = td.traverse(cui1Node);
    for(Path path : traverser){
      int len = path.length();
      if(distance == -1 || len < distance){
        distance = len;
      }
    }
    tx.success();
  }
  return distance;
}
 
开发者ID:tmills,项目名称:umls-graph-api,代码行数:25,代码来源:GraphFunctions.java

示例2: printNeoFriends

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
public String printNeoFriends() {
	try (Transaction tx = graphDb.beginTx()) {
		Node neoNode = getNeoNode();
		// START SNIPPET: friends-usage
		int numberOfFriends = 0;
		String output = neoNode.getProperty("name") + "'s friends:\n";
		Traverser friendsTraverser = getFriends(neoNode);
		for (Path friendPath : friendsTraverser) {
			output += "At depth " + friendPath.length() + " => " + friendPath.endNode().getProperty("name") + "\n";
			numberOfFriends++;
		}
		output += "Number of friends found: " + numberOfFriends + "\n";
		// END SNIPPET: friends-usage
		return output;
	}
}
 
开发者ID:stefano-bragaglia,项目名称:NeoDD,代码行数:17,代码来源:Quel.java

示例3: expand

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
@Override
public final Iterable<Relationship> expand(final Path path, final BranchState state) {

    List<Relationship> result = new ArrayList<>();

    if (this.since == Long.MIN_VALUE && this.until == Long.MAX_VALUE) {
        return path.endNode().getRelationships();
    }

    if (path.length() >= this.depth) {
        return result;
    }

    for (Relationship rel : path.endNode().getRelationships()) {
        long current = Long.parseLong(rel.getProperty("timestamp").toString());
        if (until > current && current > since) {
            result.add(rel);
        }
    }

    return result;
}
 
开发者ID:inveniosoftware-contrib,项目名称:obelix,代码行数:23,代码来源:TimeStampExpander.java

示例4: expand

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
@Override
public Iterable<Relationship> expand(Path path, BranchState branchState) {
    if (path.endNode().hasLabel(stopLabel)) {
        return Collections.emptyList();
    }
    if (path.length() % 2 == 0) {
        return path.endNode().getRelationships(Direction.INCOMING);
    } else {
        return path.endNode().getRelationships(Direction.OUTGOING);
    }
}
 
开发者ID:maxdemarzi,项目名称:cypher_hip_hop,代码行数:12,代码来源:HipHopExpander.java

示例5: evaluate

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
@Override
public Evaluation evaluate(Path path, BranchState<Double> branchState) {
    // Path with just the single node, ignore it and continue
    if (path.length() == 0 ) {
        return Evaluation.INCLUDE_AND_CONTINUE;
    }
    // Make sure last Equipment voltage is equal to or lower than previous voltage
    Double voltage = (Double) path.endNode().getProperty("voltage", 999.0);
    if (voltage <= branchState.getState()) {
        return Evaluation.INCLUDE_AND_CONTINUE;
    } else {
        return Evaluation.EXCLUDE_AND_PRUNE;
    }
}
 
开发者ID:maxdemarzi,项目名称:power_grid,代码行数:15,代码来源:EnergizationEvaluator.java

示例6: printMatrixHackers

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
public String printMatrixHackers() {
	try (Transaction tx = graphDb.beginTx()) {
		// START SNIPPET: find--hackers-usage
		String output = "Hackers:\n";
		int numberOfHackers = 0;
		Traverser traverser = findHackers(getNeoNode());
		for (Path hackerPath : traverser) {
			output += "At depth " + hackerPath.length() + " => " + hackerPath.endNode().getProperty("name") + "\n";
			numberOfHackers++;
		}
		output += "Number of hackers found: " + numberOfHackers + "\n";
		// END SNIPPET: find--hackers-usage
		return output;
	}
}
 
开发者ID:stefano-bragaglia,项目名称:NeoDD,代码行数:16,代码来源:Quel.java

示例7: evaluate

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
@Override
public Evaluation evaluate(Path path) {
    if (path.length() < length) {
        return Evaluation.EXCLUDE_AND_CONTINUE;
    }

    Node lastNode = path.endNode();
    if (!lastNode.hasLabel(Labels.AirportDay)){
        return Evaluation.EXCLUDE_AND_CONTINUE;
    } else if (destinations.contains( ((String)lastNode.getProperty("key")).substring(0,3) )) {
        return Evaluation.INCLUDE_AND_PRUNE;
    }
    return Evaluation.EXCLUDE_AND_PRUNE;
}
 
开发者ID:maxdemarzi,项目名称:neo_airlines,代码行数:15,代码来源:ReachedDestinationAtEvaluator.java

示例8: getTaxon

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
Optional<Node> getTaxon(Node source) {
  for (Path path : taxonDescription.traverse(source)) {
    if (path.length() > 0 && path.lastRelationship().isType(inTaxon)) {
      return Optional.of(path.endNode());
    }
  }
  return Optional.empty();
}
 
开发者ID:SciGraph,项目名称:golr-loader,代码行数:9,代码来源:GolrLoader.java

示例9: getChromosome

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
Optional<Node> getChromosome(Node source) {
  for (Path path : chromosomeDescription.traverse(source)) {
    if (path.length() > 0 && path.lastRelationship().isType(OwlRelationships.RDF_TYPE)) {
      if (chromsomeEntailment.contains(path.endNode())) {
        return Optional.of(path.lastRelationship().getOtherNode(path.endNode()));
      }
    }
  }
  return Optional.empty();
}
 
开发者ID:SciGraph,项目名称:golr-loader,代码行数:11,代码来源:GolrLoader.java

示例10: evaluate

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
@Override
public Evaluation evaluate(Path path) {
    if (!path.endNode().hasRelationship(Direction.OUTGOING)) {
        leaves++;
        depthSum += path.length();
    }

    return Evaluation.EXCLUDE_AND_CONTINUE;
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:10,代码来源:ViralLinkDaoNeo4j.java

示例11: evaluate

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
@Override
public Evaluation evaluate(Path path) {
  long currentId = path.endNode().getId();
  if (!nodePredicate.apply(path.endNode())) {
    inMemoryIndex.get(currentId);
    return Evaluation.EXCLUDE_AND_PRUNE;
  }

  long startId = path.startNode().getId(); // Vi
  InOutList listPair = inMemoryIndex.get(currentId);

  if (0 == path.length()) {
    // first node in the traverse - add itself to the in-out list
    listPair.getInList().add(currentId);
    listPair.getOutList().add(currentId);
    return Evaluation.INCLUDE_AND_CONTINUE;
  }
  else if (direction == Direction.INCOMING ) {
    // doing reverse BFS
    if (nodesAreConnected(currentId, startId)) {
      return Evaluation.EXCLUDE_AND_PRUNE;
    } else {
      listPair.getOutList().add(startId);
      return Evaluation.INCLUDE_AND_CONTINUE;
    }
  } else {
    //doing BFS
    if (nodesAreConnected(startId, currentId)) { // cur is w
      return Evaluation.EXCLUDE_AND_PRUNE;
    } else {
      listPair.getInList().add(startId);
      return Evaluation.INCLUDE_AND_CONTINUE;
    }
  }
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:36,代码来源:ReachabilityEvaluator.java

示例12: pruneAfterDepth

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
/**
 * A {@link PruneEvaluator} which prunes everything beyond {@code depth}.
 * @param depth the depth to prune beyond (after).
 * @return a {@link PruneEvaluator} which prunes everything after
 * {@code depth}.
 * @deprecated because of the introduction of {@link Evaluator}. The equivalent
 * is {@link Evaluators#toDepth(int)}.
 */
public static PruneEvaluator pruneAfterDepth( final int depth )
{
    return new PruneEvaluator()
    {
        public boolean pruneAfter( Path position )
        {
            return position.length() >= depth;
        }
    };
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:19,代码来源:Traversal.java

示例13: evaluate

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
public Evaluation evaluate( Path path )
{
    // Before the Evaluator, when PruneEvaluator was used individually a PruneEvaluator
    // was never called with the start node as argument. This condition mimics that behaviour.
    if ( path.length() == 0 )
    {
        return Evaluation.INCLUDE_AND_CONTINUE;
    }
    return pruning.pruneAfter( path ) ? Evaluation.INCLUDE_AND_PRUNE : Evaluation.INCLUDE_AND_CONTINUE;
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:11,代码来源:TraversalDescriptionImpl.java

示例14: toDepth

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
/**
 * Returns an {@link Evaluator} which includes positions down to {@code depth}
 * and prunes everything deeper than that.
 * 
 * @param depth the max depth to traverse to.
 * @return Returns an {@link Evaluator} which includes positions down to
 * {@code depth} and prunes everything deeper than that.
 */
public static Evaluator toDepth( final int depth )
{
    return new Evaluator()
    {
        public Evaluation evaluate( Path path )
        {
            return path.length() < depth ? Evaluation.INCLUDE_AND_CONTINUE : Evaluation.INCLUDE_AND_PRUNE;
        }
    };
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:19,代码来源:Evaluators.java

示例15: fromDepth

import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
/**
 * Returns an {@link Evaluator} which only includes positions from {@code depth}
 * and deeper and never prunes anything.
 * 
 * @param depth the depth to start include positions from.
 * @return Returns an {@link Evaluator} which only includes positions from
 * {@code depth} and deeper and never prunes anything.
 */
public static Evaluator fromDepth( final int depth )
{
    return new Evaluator()
    {
        public Evaluation evaluate( Path path )
        {
            return path.length() < depth ? Evaluation.EXCLUDE_AND_CONTINUE : Evaluation.INCLUDE_AND_CONTINUE;
        }
    };
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:19,代码来源:Evaluators.java


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