Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void betterTentativePath()
        public virtual void BetterTentativePath()
        {
            // GIVEN
            EstimateEvaluator <double> estimator = (node, goal) => ( double? )node.getProperty("estimate");
            PathFinder <WeightedPath>  finder    = aStar(PathExpanders.allTypesAndDirections(), doubleCostEvaluator("weight", 0d), estimator);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.Node node1 = graph.makeNode("1", "estimate", 0.003d);
            Node node1 = Graph.makeNode("1", "estimate", 0.003d);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.Node node2 = graph.makeNode("2", "estimate", 0.002d);
            Node node2 = Graph.makeNode("2", "estimate", 0.002d);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.Node node3 = graph.makeNode("3", "estimate", 0.001d);
            Node node3 = Graph.makeNode("3", "estimate", 0.001d);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.Node node4 = graph.makeNode("4", "estimate", 0d);
            Node node4 = Graph.makeNode("4", "estimate", 0d);

            Graph.makeEdge("1", "3", "weight", 0.253d);
            Graph.makeEdge("1", "2", "weight", 0.018d);
            Graph.makeEdge("2", "4", "weight", 0.210d);
            Graph.makeEdge("2", "3", "weight", 0.180d);
            Graph.makeEdge("2", "3", "weight", 0.024d);
            Graph.makeEdge("3", "4", "weight", 0.135d);
            Graph.makeEdge("3", "4", "weight", 0.013d);

            // WHEN
            WeightedPath best14 = finder.FindSinglePath(node1, node4);

            // THEN
            assertPath(best14, node1, node2, node3, node4);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns an <seealso cref="PathFinder"/> which uses the A* algorithm to find the
 /// cheapest path between two nodes. The definition of "cheap" is the lowest
 /// possible cost to get from the start node to the end node, where the cost
 /// is returned from {@code lengthEvaluator} and {@code estimateEvaluator}.
 /// These returned paths cannot contain loops (i.e. a node cannot occur more
 /// than once in any returned path).
 ///
 /// See http://en.wikipedia.org/wiki/A*_search_algorithm for more
 /// information.
 /// </summary>
 /// <param name="expander"> the <seealso cref="PathExpander"/> to use for expanding
 /// <seealso cref="Relationship"/>s for each <seealso cref="Path"/>. </param>
 /// <param name="lengthEvaluator"> evaluator that can return the cost represented
 /// by each relationship the algorithm traverses. </param>
 /// <param name="estimateEvaluator"> evaluator that returns an (optimistic)
 /// estimation of the cost to get from the current node (in the traversal)
 /// to the end node. </param>
 /// <returns> an algorithm which finds the cheapest path between two nodes
 /// using the A* algorithm. </returns>
 public static PathFinder <WeightedPath> AStar(PathExpander expander, CostEvaluator <double> lengthEvaluator, EstimateEvaluator <double> estimateEvaluator)
 {
     return(new AStar(expander, lengthEvaluator, estimateEvaluator));
 }