void SetSumToNextVertex(GraphVertexInfo info) { info.IsUnvisited = false; foreach (var e in info.Vertex.Edges) { var nextInfo = GetVertexInfo(e.ConnectedVertex); var sum = info.EdgesWeightSum + e.EdgeWeight; if (sum < nextInfo.EdgesWeightSum) { nextInfo.EdgesWeightSum = sum; nextInfo.PreviousVertex = info.Vertex; } } }
public GraphVertexInfo FindUnvisitedVertexWithMinSum() { var minValue = int.MaxValue; GraphVertexInfo minVertexInfo = null; foreach (var i in infos) { if (i.IsUnvisited && i.EdgesWeightSum < minValue) { minVertexInfo = i; minValue = i.EdgesWeightSum; } } return(minVertexInfo); }