Beispiel #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);
     }
 }
Beispiel #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  - РАботает
        }
Beispiel #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); //- РАботает
        }
Beispiel #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);
        }
Beispiel #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++;
            }
        }
Beispiel #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");
            }
        }
Beispiel #7
0
 static void TaskFloyd(Graph_R graph)
 {
     graph.Floyd();
 }