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


Java GraphAlgoFactory.allPaths方法代码示例

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


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

示例1: traverse

import org.neo4j.graphalgo.GraphAlgoFactory; //导入方法依赖的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();
		}
	}
}
 
开发者ID:stefano-bragaglia,项目名称:NeoDD,代码行数:21,代码来源:Propoli.java

示例2: stamp

import org.neo4j.graphalgo.GraphAlgoFactory; //导入方法依赖的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();
		}
	}
}
 
开发者ID:stefano-bragaglia,项目名称:NeoDD,代码行数:25,代码来源:Propoli.java

示例3: analyseDb

import org.neo4j.graphalgo.GraphAlgoFactory; //导入方法依赖的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();
	}
}
 
开发者ID:stefano-bragaglia,项目名称:NeoDD,代码行数:22,代码来源:Application.java

示例4: traverse

import org.neo4j.graphalgo.GraphAlgoFactory; //导入方法依赖的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;
}
 
开发者ID:stefano-bragaglia,项目名称:NeoDD,代码行数:19,代码来源:BDD.java

示例5: stamp

import org.neo4j.graphalgo.GraphAlgoFactory; //导入方法依赖的package包/类
public void stamp() {
	if (null != graph && null != root) {
		try (Transaction tx = graph.beginTx()) {

			// Traverser traverser =
			// graph.traversalDescription().relationships(RelTypes.LINKS,
			// Direction.OUTGOING)
			// .evaluator(Evaluators.excludeStartPosition()).traverse(root);
			// for (Path path : traverser) {

			PathFinder<Path> finder = GraphAlgoFactory.allPaths(//
					PathExpanders.forTypeAndDirection(RelTypes.LINKS, Direction.OUTGOING), 4); // 4
																								// is
																								// the
																								// number
																								// of
																								// nodes
																								// +
																								// 1
			Iterable<Path> paths = finder.findAllPaths(root, done);
			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:%d,%.2f]-> ", RelTypes.LINKS, relationship.getProperty(ID), relationship.getProperty(PROB, 1.0));
					System.out.format("(%s)", relationship.getEndNode().getProperty(ID));
				}
				System.out.println();
				// System.out.println(Paths.defaultPathToString(path));
			}
			tx.success();
		}
	}
}
 
开发者ID:stefano-bragaglia,项目名称:NeoDD,代码行数:39,代码来源:BiDiDi.java

示例6: correlate

import org.neo4j.graphalgo.GraphAlgoFactory; //导入方法依赖的package包/类
public double correlate(Node source, Node target, RelationshipType type, Direction dir, Object... more) {
	if (null == source)
		throw new IllegalArgumentException("Illegal 'source' argument in Problem.correlate(Node, Node, RelationshipType, Direction, Object...): " + source);
	if (null == target)
		throw new IllegalArgumentException("Illegal 'target' argument in Problem.correlate(Node, Node, RelationshipType, Direction, Object...): " + target);
	if (null == type)
		throw new IllegalArgumentException("Illegal 'type' argument in Problem.correlate(Node, Node, RelationshipType, Direction, Object...): " + type);
	if (null == dir)
		throw new IllegalArgumentException("Illegal 'dir' argument in Problem.correlate(Node, Node, RelationshipType, Direction, Object...): " + dir);
	if (source.equals(target))
		return 1.0;
	try (Transaction ignore = graph.beginTx()) {
		PathExpander<Object> expander = null;
		if (null == more || 0 == more.length)
			expander = PathExpanders.forTypeAndDirection(type, dir);
		else {
			RelationshipType t = (RelationshipType) more[0];
			Direction d = (Direction) more[1];
			expander = PathExpanders.forTypesAndDirections(type, dir, t, d, Arrays.copyOfRange(more, 2, more.length));
		}
		PathFinder<Path> finder = GraphAlgoFactory.allPaths(expander, 1 + count);
		Iterable<Path> paths = finder.findAllPaths(source, target);

		Set<Relationship> relationships = new HashSet<>();
		Set<Set<Relationship>> expression = new HashSet<>();
		for (Path path : paths) {
			Set<Relationship> item = new HashSet<>();
			for (Relationship relationship : path.relationships()) {
				relationships.add(relationship);
				item.add(relationship);
			}
			expression.add(item);
		}

		BDD bdd = new BDD(expression, relationships);
		bdd.dump("bdd.gv");
		return bdd.traverse();
	}
}
 
开发者ID:stefano-bragaglia,项目名称:NeoDD,代码行数:40,代码来源:Problem.java


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