//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturnPathsInIncreasingOrderOfCost() public virtual void ShouldReturnPathsInIncreasingOrderOfCost() { /* * * ----- (e) - 1 - (f) --- * / \ * / ------- (a) -------- \ * 1 / \ \ 2 * | 2 0 0 | * | / \ \| * (s) - 1 - (c) - 1 - (d) - 1 - (t) * \ / * -- 1 - (b) - 1 - * */ Node s = Graph.makeNode("s"); Node t = Graph.makeNode("t"); Graph.makeEdgeChain("s,e,f", "length", 1.0); Graph.makeEdge("f", "t", "length", 2); Graph.makeEdge("s", "a", "length", 2); Graph.makeEdge("a", "t", "length", 0); Graph.makeEdge("s", "c", "length", 1); Graph.makeEdge("c", "d", "length", 1); Graph.makeEdge("s", "b", "length", 1); Graph.makeEdge("b", "d", "length", 1); Graph.makeEdge("d", "a", "length", 0); Graph.makeEdge("d", "t", "length", 1); PathExpander expander = PathExpanders.allTypesAndDirections(); Dijkstra algo = new Dijkstra(expander, CommonEvaluators.doubleCostEvaluator("length"), PathInterestFactory.all(NoneStrictMath.EPSILON)); IEnumerator <WeightedPath> paths = algo.FindAllPaths(s, t).GetEnumerator(); for (int i = 1; i <= 3; i++) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue("Expected at least " + i + " path(s)", paths.hasNext()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue("Expected 3 paths of cost 2", NoneStrictMath.Equals(paths.next().weight(), 2)); } for (int i = 1; i <= 3; i++) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue("Expected at least " + i + " path(s)", paths.hasNext()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue("Expected 3 paths of cost 3", NoneStrictMath.Equals(paths.next().weight(), 3)); } //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue("Expected at least 7 paths", paths.hasNext()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue("Expected 1 path of cost 4", NoneStrictMath.Equals(paths.next().weight(), 4)); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse("Expected exactly 7 paths", paths.hasNext()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void canFetchLongerPaths() public virtual void CanFetchLongerPaths() { /* * 1-(b)-1 * / \ * (s) - 1 - (a) - 1 - (c) - 10 - (d) - 10 - (t) * */ Node s = Graph.makeNode("s"); Node a = Graph.makeNode("a"); Node b = Graph.makeNode("b"); Node c = Graph.makeNode("c"); Node d = Graph.makeNode("d"); Node t = Graph.makeNode("t"); Graph.makeEdge("s", "a", "length", 1); Graph.makeEdge("a", "c", "length", 1); Graph.makeEdge("s", "b", "length", 1); Graph.makeEdge("b", "a", "length", 1); Graph.makeEdge("c", "d", "length", 10); Graph.makeEdge("d", "t", "length", 10); PathExpander expander = PathExpanders.allTypesAndDirections(); Dijkstra algo = new Dijkstra(expander, CommonEvaluators.doubleCostEvaluator("length"), PathInterestFactory.all(NoneStrictMath.EPSILON)); IEnumerator <WeightedPath> paths = algo.FindAllPaths(s, t).GetEnumerator(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue("Expected at least one path.", paths.hasNext()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertPath(paths.next(), s, a, c, d, t); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue("Expected two paths", paths.hasNext()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertPath(paths.next(), s, b, a, c, d, t); }
public Dijkstra(PathExpander expander, InitialBranchState stateFactory, CostEvaluator <double> costEvaluator, bool stopAfterLowestCost) { this._expander = expander; this._costEvaluator = costEvaluator; this._stateFactory = stateFactory; _interest = stopAfterLowestCost ? PathInterestFactory.allShortest(NoneStrictMath.EPSILON) : PathInterestFactory.all(NoneStrictMath.EPSILON); _epsilon = NoneStrictMath.EPSILON; this._stateInUse = true; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = 5000) public void testForLoops() public virtual void TestForLoops() { /* * * (b) * / \ 0 * 0 0 / \ - 0 - (c1) - 0 - * \ / \/ / \ * (s) - 1 - (a1) - 1 - (a2) - 1 - (a3) (a4) - 1 - (t) * \ / * - 0 - (c2) - 0 - * */ using (Transaction tx = GraphDb.beginTx()) { Node s = Graph.makeNode("s"); Node t = Graph.makeNode("t"); // Blob loop Graph.makeEdge("s", "a1", "length", 1); Graph.makeEdge("a1", "b", "length", 0); Graph.makeEdge("b", "a1", "length", 0); // Self loop Graph.makeEdge("a1", "a2", "length", 1); Graph.makeEdge("a2", "a2", "length", 0); // Diamond loop Graph.makeEdge("a2", "a3", "length", 1); Graph.makeEdge("a3", "c1", "length", 0); Graph.makeEdge("a3", "c2", "length", 0); Graph.makeEdge("c1", "a4", "length", 0); Graph.makeEdge("c1", "a4", "length", 0); Graph.makeEdge("a4", "t", "length", 1); PathExpander expander = PathExpanders.allTypesAndDirections(); Dijkstra algo = new Dijkstra(expander, CommonEvaluators.doubleCostEvaluator("length"), PathInterestFactory.all(NoneStrictMath.EPSILON)); IEnumerator <WeightedPath> paths = algo.FindAllPaths(s, t).GetEnumerator(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue("Expected at least one path", paths.hasNext()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals("Expected first path of length 6", 6, paths.next().length()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue("Expected at least two paths", paths.hasNext()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals("Expected second path of length 6", 6, paths.next().length()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse("Expected exactly two paths", paths.hasNext()); tx.Success(); } }
public Dijkstra(PathExpander expander, CostEvaluator <double> costEvaluator, bool stopAfterLowestCost) : this(expander, costEvaluator, NoneStrictMath.EPSILON, stopAfterLowestCost ? PathInterestFactory.allShortest(NoneStrictMath.EPSILON) : PathInterestFactory.all(NoneStrictMath.EPSILON)) { }