Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Job           hello      = new Job(23, 23);
            JobFileReader fileReader = new JobFileReader();

            (int, Job[])myJobData = fileReader.ReadJobFile(@"C:\Users\Paul\Documents\Open Source Society for Computer Science (OSSU)\Algorithms Coursera\Programming Assignments\Week 9 Programming Assignment\TestCases\Test Case 1.txt");
            JobScheduler jobScheduler = new JobScheduler();

            Job[] gg = jobScheduler.DifferenceCriterion(myJobData.Item2);
            foreach (Job j in gg)
            {
                Console.WriteLine(j._jobValue);
            }
            Console.WriteLine("---------------------------");
            Week9FileReader fileReader2 = new Week9FileReader();

            Dictionary <int, List <(int?, int)> > adjacentGraph = fileReader2.GraphFileReader(@"C:\Users\Paul\Documents\Open Source Society for Computer Science (OSSU)\Algorithms Coursera\Programming Assignments\Week 9 Programming Assignment with DLL\Assignment9\MST Data.txt");
            Prim  prim  = new Prim();
            Graph graph = new Graph(adjacentGraph);

            Console.WriteLine("");
            List <Edge> tree = prim.Apply(graph, graph._vertices[1]);

            int myAnswer = 0;

            foreach (Edge ed in tree)
            {
                myAnswer += ed._length;
            }
            Console.WriteLine("MST Length: " + myAnswer);
            Console.ReadKey();
        }
Ejemplo n.º 2
0
    public void MST_UnitTest_1()
    {
        // Arrange
        Week9FileReader fileReader = new Week9FileReader();
        Prim            prim       = new Prim();

        Dictionary <int, List <(int?, int)> > adjacentGraph = fileReader.GraphFileReader(@"C:\Users\Paul\Documents\Open Source Society for Computer Science (OSSU)\Algorithms Coursera\Programming Assignments\Week 9 Programming Assignment with DLL\Assignment9\Unit Test MST.txt");
        Graph graph           = new Graph(adjacentGraph);
        int   MSTLengthAnswer = 7;

        // Act
        List <Edge> mst      = prim.Apply(graph, graph._vertices[1]);
        int         myAnswer = 0;

        foreach (Edge ed in mst)
        {
            myAnswer += ed._length;
        }

        // Assert
        Assert.Equal(MSTLengthAnswer, myAnswer);
    }