本文整理汇总了Java中org.neo4j.graphdb.Path类的典型用法代码示例。如果您正苦于以下问题:Java Path类的具体用法?Java Path怎么用?Java Path使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Path类属于org.neo4j.graphdb包,在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validates_supported_simple_types
import org.neo4j.graphdb.Path; //导入依赖的package包/类
@Test
public void validates_supported_simple_types()
{
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( String.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Number.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Long.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( TypeKind.LONG ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Double.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( TypeKind.DOUBLE ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Boolean.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( TypeKind.BOOLEAN ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Path.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Node.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Relationship.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Object.class ) ) ).isTrue();
}
示例2: validates_supported_generic_types
import org.neo4j.graphdb.Path; //导入依赖的package包/类
@Test
public void validates_supported_generic_types()
{
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Map.class, String.class, Object.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( HashMap.class, String.class, Object.class ) ) )
.isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( LinkedHashMap.class, String.class, Object.class ) ) )
.isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( List.class, String.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( LinkedList.class, Number.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( ArrayList.class, Long.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( List.class, Double.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( List.class, Boolean.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( List.class, Path.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( List.class, Node.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( List.class, Relationship.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils().typeOf( List.class, Object.class ) ) ).isTrue();
assertThat( visitor().visit( typeMirrorTestUtils()
.typeOf( List.class, typeMirrorTestUtils().typeOf( Map.class, String.class, Object.class ) ) ) )
.isTrue();
assertThat( visitor().visit( typeMirrorTestUtils()
.typeOf( List.class, typeMirrorTestUtils().typeOf( LinkedList.class, Long.class ) ) ) ).isTrue();
}
示例3: supported_simple_type_is_valid
import org.neo4j.graphdb.Path; //导入依赖的package包/类
@Test
public void supported_simple_type_is_valid()
{
assertThat( validator.test( typeMirrorTestUtils.typeOf( BOOLEAN ) ) ).isTrue();
assertThat( validator.test( typeMirrorTestUtils.typeOf( LONG ) ) ).isTrue();
assertThat( validator.test( typeMirrorTestUtils.typeOf( DOUBLE ) ) ).isTrue();
assertThat( validator.test( typeMirrorTestUtils.typeOf( Boolean.class ) ) ).isTrue();
assertThat( validator.test( typeMirrorTestUtils.typeOf( Long.class ) ) ).isTrue();
assertThat( validator.test( typeMirrorTestUtils.typeOf( Double.class ) ) ).isTrue();
assertThat( validator.test( typeMirrorTestUtils.typeOf( String.class ) ) ).isTrue();
assertThat( validator.test( typeMirrorTestUtils.typeOf( Number.class ) ) ).isTrue();
assertThat( validator.test( typeMirrorTestUtils.typeOf( Object.class ) ) ).isTrue();
assertThat( validator.test( typeMirrorTestUtils.typeOf( Node.class ) ) ).isTrue();
assertThat( validator.test( typeMirrorTestUtils.typeOf( Relationship.class ) ) ).isTrue();
assertThat( validator.test( typeMirrorTestUtils.typeOf( Path.class ) ) ).isTrue();
}
示例4: getHypernyms
import org.neo4j.graphdb.Path; //导入依赖的package包/类
public static List<String> getHypernyms(String cui){
List<String> hypers = new ArrayList<>();
try ( Transaction tx = graphDb.beginTx() ){
TraversalDescription td = graphDb.traversalDescription()
.breadthFirst()
.relationships(RelReader.RelTypes.ISA, Direction.OUTGOING)
.evaluator(Evaluators.excludeStartPosition());
Node cuiNode = graphDb.findNode(RelReader.DictLabels.Concept, RelReader.CUI_PROPERTY, cui);
if(cuiNode == null) return hypers;
Traverser traverser = td.traverse(cuiNode);
for(Path path : traverser){
hypers.add(path.endNode().getProperty(RelReader.CUI_PROPERTY).toString());
}
tx.success();
}
return hypers;
}
示例5: getHyponyms
import org.neo4j.graphdb.Path; //导入依赖的package包/类
public static List<String> getHyponyms(String cui){
List<String> hypos = new ArrayList<>();
try ( Transaction tx = graphDb.beginTx() ){
TraversalDescription td = graphDb.traversalDescription()
.breadthFirst()
.relationships(RelReader.RelTypes.ISA, Direction.INCOMING)
.evaluator(Evaluators.excludeStartPosition());
Node cuiNode = graphDb.findNode(RelReader.DictLabels.Concept, RelReader.CUI_PROPERTY, cui);
if(cuiNode == null) return hypos;
Traverser traverser = td.traverse(cuiNode);
for(Path path : traverser){
hypos.add(path.endNode().getProperty(RelReader.CUI_PROPERTY).toString());
}
tx.success();
}
return hypos;
}
示例6: 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;
}
示例7: testRelReader
import org.neo4j.graphdb.Path; //导入依赖的package包/类
@Test
public void testRelReader() throws IOException{
RelReader reader = new RelReader(neo4jLocation);
reader.batchBuildGraph(new File("my_test_umls/"), "CtakesAllTuis.txt", "SNOMEDCT_US");
GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(new File(neo4jLocation));
try ( Transaction tx = db.beginTx() ){
TraversalDescription td = db.traversalDescription()
.breadthFirst()
.relationships(RelReader.RelTypes.ISA, Direction.INCOMING)
.evaluator(Evaluators.excludeStartPosition());
Node cuiNode = db.findNode(RelReader.DictLabels.Concept, RelReader.CUI_PROPERTY, "C0007102");
Assert.assertNotNull(cuiNode);
Traverser traverser = td.traverse(cuiNode);
for(Path path : traverser){
System.out.println("At depth " + path.length() + " => " + path.endNode().getProperty("cui"));
}
}
db.shutdown();
}
示例8: traverse
import org.neo4j.graphdb.Path; //导入依赖的package包/类
public void traverse() {
if (null != graph && null != root) {
try (Transaction tx = graph.beginTx()) {
PathFinder<Path> finder = GraphAlgoFactory.allPaths(
PathExpanders.forTypesAndDirections(RelTypes.CHILD_HI, Direction.OUTGOING, RelTypes.CHILD_LO, Direction.OUTGOING), 5);
// 5 is the number of original relationships + 1
Iterable<Path> paths = finder.findAllPaths(root, one);
double total = 0.0;
for (Path path : paths) {
double current = 1.0;
for (Relationship relationship : path.relationships()) {
current *= (double) relationship.getProperty(PROB, 1.0);
}
total += current;
}
System.out.format("The probability is %.2f.\n", total);
tx.success();
}
}
}
示例9: stamp
import org.neo4j.graphdb.Path; //导入依赖的package包/类
public void stamp() {
if (null != graph && null != root) {
try (Transaction tx = graph.beginTx()) {
PathFinder<Path> finder = GraphAlgoFactory.allPaths(
PathExpanders.forTypesAndDirections(RelTypes.CHILD_HI, Direction.OUTGOING, RelTypes.CHILD_LO, Direction.OUTGOING), 5);
// 5 is the number of original relationships + 1
Iterable<Path> paths = finder.findAllPaths(root, one);
for (Path path : paths) {
boolean first = true;
for (Relationship relationship : path.relationships()) {
if (first) {
System.out.format("(%s)", relationship.getStartNode().getProperty(ID));
first = false;
}
System.out.format(" --[%s,%.2f]-> ", relationship.getType().name(), relationship.getProperty(PROB, 1.0));
System.out.format("(%s)", relationship.getEndNode().getProperty(ID));
}
System.out.println();
}
tx.success();
}
}
}
示例10: analyseDb
import org.neo4j.graphdb.Path; //导入依赖的package包/类
private void analyseDb() {
Transaction tx = graphDb.beginTx();
try {
PathFinder<Path> finder = GraphAlgoFactory.allPaths(//
PathExpanders.forTypeAndDirection(RelTypes.KNOWS, Direction.BOTH), -1);
Iterable<Path> paths = finder.findAllPaths(firstNode, secondNode);
for (Path path : paths) {
for (Node node : path.nodes()) {
for (String prop : node.getPropertyKeys())
System.out.print(prop);
System.out.print(node.toString());
}
for (Relationship relationship : path.relationships())
System.out.print(relationship.toString());
}
tx.success();
} finally {
tx.finish();
}
}
示例11: 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;
}
}
示例12: traverse
import org.neo4j.graphdb.Path; //导入依赖的package包/类
public double traverse() {
if (null != root && value < 0.0) {
try (Transaction ignore = graph.beginTx()) {
value = 0.0;
PathFinder<Path> finder = GraphAlgoFactory.allPaths(
PathExpanders.forTypesAndDirections(RelType.LO_CHILD, Direction.OUTGOING, RelType.HI_CHILD, Direction.OUTGOING), max);
Iterable<Path> paths = finder.findAllPaths(root, one);
for (Path path : paths) {
double current = 1.0;
for (Relationship relationship : path.relationships()) {
current *= (double) relationship.getProperty(PROB, 1.0);
}
value += current;
}
}
}
return value;
}
示例13: evaluate
import org.neo4j.graphdb.Path; //导入依赖的package包/类
/**
* Evaluates a node and determines whether to include and / or continue.
* Continues on and returns exactly those nodes that:
* <ul>
* <li>haven't been visited yet and</li>
* <li>are the start node
* <ul>
* <li>have a sequence < threshold (and thus belong to the same cluster)</li>
* </ul>
* </ul>
*/
@Override
public Evaluation evaluate(Path path) {
Node end = path.endNode();
int score = is.compute(new Neo4jScoreContainer(end));
end.setProperty(SequenceProperties.INTERESTINGNESS.name(), score);
String id = (String) end.getProperty(ID.name());
if (!visited.contains(id)
&& (path.startNode().getId() == path.endNode().getId()
|| score < threshold)) {
visited.add(id);
return Evaluation.INCLUDE_AND_CONTINUE;
}
return Evaluation.EXCLUDE_AND_PRUNE;
}
示例14: call
import org.neo4j.graphdb.Path; //导入依赖的package包/类
@Override
public Map<String, Set<Long>> call() throws Exception {
logger.info("Processsing " + category);
Map<String, Set<Long>> map = new HashMap<String, Set<Long>>();
Set<Long> nodeSet = new HashSet<Long>();
Transaction tx = graphDb.beginTx();
try {
for (Path position : graphDb.traversalDescription().uniqueness(Uniqueness.NODE_GLOBAL).depthFirst()
.relationships(OwlRelationships.RDFS_SUBCLASS_OF, Direction.INCOMING).relationships(OwlRelationships.RDF_TYPE, Direction.INCOMING)
.relationships(OwlRelationships.OWL_EQUIVALENT_CLASS, Direction.BOTH).relationships(OwlRelationships.OWL_SAME_AS, Direction.BOTH)
.traverse(root)) {
Node end = position.endNode();
nodeSet.add(end.getId());
}
logger.info("Discovered " + nodeSet.size() + " nodes for " + category);
map.put(category, nodeSet);
} catch (Exception e) {
logger.warning("IRI not found for category: " + category);
} finally {
tx.success();
tx.close();
}
return map;
}
示例15: getEdges
import org.neo4j.graphdb.Path; //导入依赖的package包/类
public Graph getEdges(RelationshipType type, boolean entail, long skip, long limit) {
String query = "MATCH path = (start)-[r:" + type.name() + (entail ? "!" : "") + "]->(end) "
+ " RETURN path "
// TODO: This slows down the query dramatically.
// + " ORDER BY ID(r) "
+ " SKIP " + skip + " LIMIT " + limit;
Graph graph = new TinkerGraph();
TinkerGraphUtil tgu = new TinkerGraphUtil(graph, curieUtil);
Result result;
try {
result = cypherUtil.execute(query);
while (result.hasNext()) {
Map<String, Object> map = result.next();
Path path = (Path) map.get("path");
tgu.addPath(path);
}
} catch (ArrayIndexOutOfBoundsException e) {
// Return and empty graph if the limit is too high...
}
return graph;
}