Пример #1
0
        public override bool Equals(object obj)
        {
            TravelPath other = obj as TravelPath;

            if (other != null)
            {
                //put cost first because it more efficent
                return(_cost.Equals(other.Cost()) &&
                       _path.Equals(other._path));
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        private TravelPath ConvertToPath(IEnumerable <TravelEdge> path, int start)
        {
            var enumerator = path.GetEnumerator();

            enumerator.MoveNext();
            int        current = start;
            TravelPath p       = new TravelPath();
            int        prev;

            do
            {
                prev    = current;
                current = enumerator.Current.getAnotherPlace(current);
                p.Add(current, GetCost(current, prev));
            }while (enumerator.MoveNext());
            return(p);
        }
Пример #3
0
        public bool isPathClear(TravelPath path)
        {
            var enumartor = path.GetEnumerator();

            enumartor.MoveNext();
            int prev = enumartor.Current;

            while (enumartor.MoveNext())
            {
                if (!isClear(prev, enumartor.Current))
                {
                    return(false);
                }
                prev = enumartor.Current;
            }

            return(true);
        }