Ejemplo n.º 1
0
        /// <summary>
        /// Processes a <see cref="PathRequest"/>
        /// </summary>
        /// <param name="pathRequest"></param>
        public void Process(PathRequest <TPath> pathRequest)
        {
            var path = _algorithm.FindPath(NodeNetwork, pathRequest, out var succes);

            Debug.WriteLine(succes ? $"{_algorithm.GetType()} has found a path" : $"{_algorithm.GetType()} did not find a path :(");
            pathRequest.FinishSolvePath(path, succes);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Processes a <see cref="PathRequest"/>
        /// </summary>
        /// <param name="pathRequest"></param>
        public void Process(PathRequest <TPath> pathRequest)
        {
            if (_pathCache == null || !_pathCache.TryGetValue(pathRequest, out var path))
            {
                path = _algorithm.FindPath(NodeNetwork, pathRequest);
                _pathCache?.Add(pathRequest, path);
            }
            var succes = path != null?_algorithm.ValidatePath(NodeNetwork, pathRequest, path) : false;

            if (path == null)
            {
                path = _algorithm.GetDefaultPath(NodeNetwork, pathRequest);
            }
            Debug.WriteLine(succes ? $"{_algorithm.GetType()} has found a path" : $"{_algorithm.GetType()} did not find a path :(");
            pathRequest.FinishSolvePath(path, succes);
        }