static void Main(string[] args) { Vectex O = new Vectex(0); Vectex A = new Vectex(1); Vectex B = new Vectex(2); Vectex C = new Vectex(3); Vectex D = new Vectex(4); Vectex[] vectexs = new Vectex[] { O, A, B, C, D }; Dictionary <Vectex, Edge[]> datas = new Dictionary <Vectex, Edge[]>(); Edge OA = new Edge(O, A, 2); Edge OB = new Edge(O, B, 3); Edge AC = new Edge(A, C, 7); Edge AD = new Edge(A, D, -1); Edge BD = new Edge(B, D, 1); Edge DC = new Edge(D, C, 2); datas.Add(O, new Edge[] { OA, OB }); datas.Add(A, new Edge[] { AC, AD }); datas.Add(B, new Edge[] { BD }); datas.Add(D, new Edge[] { DC }); int[] results = Ford(datas, vectexs); foreach (var ii in results) { Console.Write(ii + " "); } Console.ReadKey(); }
public Edge(Vectex from, Vectex to, int weight) { From = from; To = to; Weight = weight; }