private void SetSumToNextVertex(VertexInfo vertexInfo)
        {
            vertexInfo.IsVisited = true;

            for (int i = 0; i < vertexInfo.Vertex.Nodes.Count; ++i)
            {
                long sum = vertexInfo.SumWeightEdges + vertexInfo.Vertex.Nodes[i].Weight;

                VertexInfo nextVertexInfo = GetVertexInfo(vertexInfo.Vertex.Nodes[i].Connectable);

                if (sum < nextVertexInfo.SumWeightEdges)
                {
                    nextVertexInfo.SumWeightEdges = Convert.ToInt32(sum);

                    nextVertexInfo.PrevVertex = vertexInfo.Vertex;
                }
            }
        }
        private VertexInfo FindMinUnvisitedVertex()
        {
            int minSum = Int32.MaxValue;

            VertexInfo minVertexInfo = null;

            foreach (var vertex in vertexInfos)
            {
                if (!vertex.IsVisited && vertex.SumWeightEdges < minSum)
                {
                    minVertexInfo = vertex;

                    minSum = vertex.SumWeightEdges;
                }
            }

            return(minVertexInfo);
        }
        public List <int> FindShortestPath(int startVertexId, int endVertexId)
        {
            VertexInfo startVertexInfo = GetVertexInfo(startVertexId);

            startVertexInfo.SumWeightEdges = 0;

            VertexInfo currentVertexInfo = null;

            while (true)
            {
                currentVertexInfo = FindMinUnvisitedVertex();

                if (currentVertexInfo == null)
                {
                    break;
                }

                SetSumToNextVertex(currentVertexInfo);
            }

            return(GetPath(startVertexId, endVertexId));
        }