コード例 #1
0
ファイル: DykstraEdgeVisitor.cs プロジェクト: F0rt1s/routing
        /// <summary>
        /// Executes the actual algorithm.
        /// </summary>
        protected override void DoRun()
        {
            // create dykstra algorithm.
            // search forward starting from sourcePaths with no restrictions.
            var dykstra = new Dykstra(_geometricGraph.Graph, _getFactor, v => Constants.NO_VERTEX,
                                      _source, _limitInSeconds, false);

            dykstra.WasEdgeFound += (v1, v2, w1, w2, e, length) =>
            {
                if (Visit == null)
                {
                    return(false);
                }

                // Calculate weight at start vertex.
                uint edgeId;
                if (e > 0)
                {
                    edgeId = (uint)e - 1;
                }
                else
                {
                    edgeId = (uint)((-e) - 1);
                }
                var edge  = _geometricGraph.GetEdge(edgeId);
                var shape = _geometricGraph.GetShape(edge);

                Visit?.Invoke(e, v1, w1, v2, w2, shape);

                return(false); // return false, returning true stops the search!
            };

            dykstra.Run();
        }