public static List<string> PrintAllPointGs(DekstraAlgorim da) { List<string> retListOfPointGs = new List<string>(); foreach (PointG p in da.PointGs) { retListOfPointGs.Add(string.Format("PointG name={0}, PointG value={1}, predok={2}", p.Name, p.ValueMetka, p.predPointG.Name ?? "нет предка")); } return retListOfPointGs; }
/// <summary> /// Получаем маршрут. /// </summary> public void GetPath(PointG[] pointGs,Rebro[] rebros) { foreach (PointG point in pointGs) { point.ValueMetka = point == beginPointG ? 0 : 999; point.IsChecked = false; } DekstraAlgorim da = new DekstraAlgorim(pointGs,rebros); da.AlgoritmRun(beginPointG); path = da.MinPath1(endPointG); inPointG = path[path.Count - 2]; FinishCoordinate.X = path[path.Count - 2].X; FinishCoordinate.Y = path[path.Count - 2].Y; }
public static List<string> PrintAllMinPaths(DekstraAlgorim da) { List<string> retListOfPointGsAndPaths = new List<string>(); foreach (PointG p in da.PointGs) { if (p != da.BeginPointG) { string s = string.Empty; foreach (PointG p1 in da.MinPath1(p)) { s += string.Format("{0} ", p1.Name); } retListOfPointGsAndPaths.Add(string.Format("PointG ={0},MinPath from {1} = {2}", p.Name, da.BeginPointG.Name, s)); } } return retListOfPointGsAndPaths; }