Exemplo n.º 1
0
        // METHODS
        public void Run(int from)
        {
            Reset();
            openSet.Add(from, 0);// start position

            while (openSet.Count != 0)
            {
                // get closest edge
                int closestEdge = openSet.Values.Min();
                System.Collections.Generic.KeyValuePair <int, int> currentEdge = openSet.FirstOrDefault(v => v.Value == closestEdge);
                // finding shorter path
                CheckNeighbours(
                    neighbourWeight: graph.GetWeightToHeighbour(currentEdge.Key),
                    currentWeight: currentEdge.Value,
                    fromEdge: 0,
                    toEdge: graph.Size);
                // remove processed edge
                openSet.Remove(currentEdge.Key);
                closedSet.Add(currentEdge.Key, currentEdge.Value);
                path.Add(currentEdge.Key);
            }
        }