Example #1
0
        private static Graph generateGraphFromFile()
        {
            bool head = true; int edges = -1;

            foreach (var line in System.IO.File.ReadLines(@"Resources\graph01.txt"))
            {
                string[] nums = line.Split(' ');
                if (head)
                {
                    graph = new SparseGraph(Convert.ToInt32(nums[0]), false);
                    // graph = new DenseGraph(Convert.ToInt32(nums[0]), false);
                    edges = Convert.ToInt32(nums[1]);
                    head  = false;
                }
                else
                {
                    graph.AddEdge(Convert.ToInt32(nums[0]), Convert.ToInt32(nums[1]));
                }
            }
            Assert.IsTrue(graph.E() == edges);
            return(graph);
        }