public void TestAppend() { var forwardPath = new EdgePath <float>(2, 10, 20, new EdgePath <float>(1, 5, 10, new EdgePath <float>(0))); var backwardPath = new EdgePath <float>(2, 10, -30, new EdgePath <float>(3, 5, -40, new EdgePath <float>(4))); var path = forwardPath.Append(backwardPath); Assert.IsNotNull(path); Assert.AreEqual(4, path.Vertex); Assert.AreEqual(20, path.Weight); Assert.AreEqual(40, path.Edge); path = path.From; Assert.IsNotNull(path); Assert.AreEqual(3, path.Vertex); Assert.AreEqual(15, path.Weight); Assert.AreEqual(30, path.Edge); path = path.From; Assert.IsNotNull(path); Assert.AreEqual(2, path.Vertex); Assert.AreEqual(10, path.Weight); Assert.AreEqual(20, path.Edge); path = path.From; Assert.IsNotNull(path); Assert.AreEqual(1, path.Vertex); Assert.AreEqual(5, path.Weight); Assert.AreEqual(10, path.Edge); path = path.From; Assert.IsNotNull(path); Assert.AreEqual(0, path.Vertex); Assert.AreEqual(0, path.Weight); Assert.AreEqual(Constants.NO_EDGE, path.Edge); Assert.IsNull(path.From); }
/// <summary> /// Gets the route to the given stop. /// </summary> public Route GetRoute(uint stop) { var path = this.GetPath(stop); var point = this.GetTargetPoint(stop); if (_backward) { var reverse = new EdgePath <float>(path.Vertex); path = reverse.Append(path); return(CompleteRouteBuilder.Build(_multimodalDb.RouterDb, _profile, point, _routerPoint, path)); } return(CompleteRouteBuilder.Build(_multimodalDb.RouterDb, _profile, _routerPoint, point, path)); }
/// <summary> /// Gets the path from source->target. /// </summary> /// <returns></returns> public EdgePath <float> GetPath() { if (!this.HasSucceeded) { throw new Exception("No results available, algorithm was not successful!"); } for (var i = 0; i < _targetPaths.Length; i++) { if (_targetPaths[i].Vertex == _bestVertex) { return(_best.Append(_targetPaths[i])); } } throw new InvalidOperationException("No path could be found to/from source/target."); }