Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public GraphVertexInfo FindUnvisitedVertexWithSum()
        {
            var             minValue      = double.MaxValue;
            GraphVertexInfo minVertexInfo = null;

            foreach (var item in infos)
            {
                if (item.IsUnvisited && item.EdgesWeightSum < minValue)
                {
                    minVertexInfo = item;
                    minValue      = item.EdgesWeightSum;
                }
            }

            return(minVertexInfo);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="info"></param>
        private void SetSumToNextVertex(GraphVertexInfo info)
        {
            info.IsUnvisited = false;

            foreach (var item in info.Vertex.Edges)
            {
                var nextInfo = GetGraphVertexInfo(item.ConnectedVertex);
                var sum      = info.EdgesWeightSum + item.EdgeWeight;

                if (sum < nextInfo.EdgesWeightSum)
                {
                    nextInfo.EdgesWeightSum = sum;
                    nextInfo.PreviousVertex = info.Vertex;
                }
            }
        }