public Graph_R(Graph_R a) { for (int i = 0; i < a.Size; i++) { SortedList <int, int> list1 = new SortedList <int, int>(a.graph[i]); graph.Add(i, list1); } }
static void Main(string[] args) { Graph_R graph = new Graph_R(); graph.Show(); // graph.RemoveNode(2); //graph.RemoveNode(4); //graph.Show(); TaskFloyd(graph); //oriented - РАботает }
static void Main(string[] args) { Graph_R graph = new Graph_R(); graph.Show(); graph.RemoveNode(2); graph.RemoveNode(4); //graph.Show(); TaskDejkstra(graph, 3); //- РАботает }
static void Main(string[] args) { Graph_R graph = new Graph_R(); graph.Show(); //graph.RemoveNode(2); //graph.RemoveNode(4); //graph.Show(); TaskFordBellman(graph, 0); }
static void TaskDejkstra(Graph_R graph, int node) { int i = 0; foreach (var dictionary in graph.Dejkstra(node)) { Console.WriteLine("The shortest way from the node: " + node + " to the node: " + dictionary.Key + " is = " + dictionary.Value.Keys[0]); i++; } }
static void TaskFordBellman(Graph_R graph, int node) { int i = 0; SortedList <int, int> d = new SortedList <int, int>(graph.Size); if (graph.FordBellman(node, d)) { foreach (KeyValuePair <int, int> distance in d) { Console.WriteLine("The shortest way from the node: " + node + " to the node: " + distance.Key + " is = " + distance.Value); i++; } } else { Console.WriteLine("There is a cycle of negative weight"); } }
static void TaskFloyd(Graph_R graph) { graph.Floyd(); }