예제 #1
0
 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);
     }
 }
예제 #2
0
        static void Main(string[] args)
        {
            Graph_R graph = new Graph_R();

            graph.Show();
            // graph.RemoveNode(2);
            //graph.RemoveNode(4);
            //graph.Show();
            TaskFloyd(graph); //oriented  - РАботает
        }
예제 #3
0
        static void Main(string[] args)
        {
            Graph_R graph = new Graph_R();

            graph.Show();
            graph.RemoveNode(2);
            graph.RemoveNode(4);
            //graph.Show();
            TaskDejkstra(graph, 3); //- РАботает
        }
예제 #4
0
        static void Main(string[] args)
        {
            Graph_R graph = new Graph_R();

            graph.Show();
            //graph.RemoveNode(2);
            //graph.RemoveNode(4);
            //graph.Show();
            TaskFordBellman(graph, 0);
        }
예제 #5
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++;
            }
        }
예제 #6
0
        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");
            }
        }
예제 #7
0
 static void TaskFloyd(Graph_R graph)
 {
     graph.Floyd();
 }