Example #1
0
 public void Setup()
 {
     LList.Add("Bill");
     LList.Add("Phil");
     LList.Add("Frank");
     LList.Add("Bobby");
 }
 public void Setup()
 {
     LList.Add("Bill");
     LList.Add("Phil");
     LList.Add("Frank");
     LList.Add("Bobby");
     Iterator = LList.Iterator;
 }
        public void TestSimpleLinkedListAddition()
        {
            var list = new SortedLinkedList <int>();

            list.Add(0);
            list.Add(1);
            list.Add(3);
            list.Add(2);

            Assert.AreEqual(2, list.ElementAt(2));
        }
        /// <summary>
        /// Tests the <see cref="SortedLinkedList{T}.Add(T)"/> method to ensure
        /// that sort order is maintained.
        /// </summary>
        public void AddShouldMaintainSortOrder()
        {
            SortedLinkedList <int> list = new SortedLinkedList <int>();

            list.Add(1);
            list.Add(7);
            list.Add(34);
            list.Add(-1);
            list.Add(9);

            Assert.AreEqual("34, 9, 7, 1, -1", list.ToString(), "Sort order should be maintained by adding values");
        }
        public void ClearElementsFromList()
        {
            var list = new SortedLinkedList <string>((a, b) => a.CompareTo(b));

            list.Add("A");
            list.Add("B");
            list.Add("C");

            Assert.Equal(list.Count, 3);

            list.Clear();
            Assert.Empty(list);
        }
Example #6
0
        public void InsertItemToBegin()
        {
            //Arrange
            int valueToInsert = 1;
            var list          = new SortedLinkedList();

            list.Add(5);
            list.Add(7);

            //Act
            list.Add(valueToInsert);

            //Assert
            CheckSorting(list);
        }
Example #7
0
        public void InsertTheSameValueTwiceToList()
        {
            //Arrange
            var list = new SortedLinkedList();

            list.Add(2);

            //Act
            list.Add(2);
            list.Add(2);

            //Assert
            Assert.Equal(3, GetLength(list));
            CheckSorting(list);
        }
        public void RemoveNotPresentElementFromList()
        {
            const string elementToRemove = "NOT Present";
            var          list            = new SortedLinkedList <string>((a, b) => a.CompareTo(b));

            list.Add("An element");
            list.Add("Present");
            list.Add("Another LMNT");

            Assert.Equal(list.Count, 3);
            Assert.False(list.Contains(elementToRemove));

            list.Remove(elementToRemove);
            Assert.Equal(list.Count, 3);
            Assert.False(list.Contains(elementToRemove));
        }
Example #9
0
        public void Add(T obj)
        {
            int tempIndex = m_list.Count == 0 ? 0 : (m_list.Last.Value.Key + 1);

            obj.TempZIndex = tempIndex;

            if (obj.LastList == this && Array.IndexOf(EnsureArray(), obj) != -1) // if we're adding a child second time, it will be raised to the top of visibility. TODO: remove this
            {
                // already added, nothing changes
                return;
            }

            m_list.Add(obj.ZIndex, obj);
            obj.LastList = this;

            m_version++;
        }
Example #10
0
        public void Add(T obj)
        {
            if (obj.LastList == this && Array.IndexOf(EnsureArray(), obj) != -1)
            {
                obj.TempZIndex = m_list.Last.Value.Key + 1;
                return;
            }
            else
            {
                obj.TempZIndex = 0;
            }

            m_list.Add(obj.ZIndex, obj);
            obj.LastList = this;

            m_version++;
        }
        public void RemoveOfSingleItemInListShouldNowBeEmpty()
        {
            SortedLinkedList <int> list = new SortedLinkedList <int>();

            list.Add(1);

            _ = list.Remove(1);
            Assert.IsTrue(list.IsEmpty, "Remove should update IsEmpty on success");
        }
        public void RemoveShouldDecrementCountWhenFound()
        {
            SortedLinkedList <int> list = new SortedLinkedList <int>();

            list.Add(1);

            Assert.IsTrue(list.Remove(1), "Remove should return true on success");
            Assert.AreEqual(0, list.Count, "Remove should decrement count on success");
        }
        public void AddToEmptyListShouldNoLongerBeEmpty()
        {
            SortedLinkedList <int> list = new SortedLinkedList <int>();

            Assert.IsTrue(list.IsEmpty, "New list should be empty");

            list.Add(1);
            Assert.IsFalse(list.IsEmpty, "Added item should no longer be empty list");
        }
        public void AddShouldIncrementCount()
        {
            SortedLinkedList <int> list = new SortedLinkedList <int>();

            Assert.AreEqual(0, list.Count, "New list should have count of 0");

            list.Add(1);
            Assert.AreEqual(1, list.Count, "Add should increment count");
        }
    /// <summary>
    /// Use this for initialization
    /// </summary>
    void Start()
    {
        rb2d = GetComponent <Rigidbody2D>();

        Graph <Waypoint> graph = GraphBuilder.Graph;

        startNode = graph.Find(GameObject.FindWithTag("Start").GetComponent <Waypoint>());
        endNode   = graph.Find(GameObject.FindWithTag("End").GetComponent <Waypoint>());

        float distance;

        foreach (GraphNode <Waypoint> node in graph.Nodes)
        {
            SearchNode <Waypoint> searchNode = new SearchNode <Waypoint>(node);
            if (node == startNode)
            {
                searchNode.Distance = 0;
            }
            searchList.Add(searchNode);
            searchDict[node] = searchNode;
        }

        while (searchList.Count > 0)
        {
            curSearchNode = searchList.ElementAt(0);
            searchList.RemoveFirst();
            curGraphNode = curSearchNode.GraphNode;
            searchDict.Remove(curGraphNode);

            if (curGraphNode == endNode)
            {
                targets = ConvertPathToString(curSearchNode);
                //PrintPathToString(targets);
            }

            foreach (GraphNode <Waypoint> curGraphNodeNeighbor in curGraphNode.Neighbors)
            {
                if (searchDict.ContainsKey(curGraphNodeNeighbor))
                {
                    distance = curSearchNode.Distance + curGraphNode.GetEdgeWeight(curGraphNodeNeighbor);
                    curSearchNodeNeighbor = searchDict[curGraphNodeNeighbor];

                    if (distance < curSearchNodeNeighbor.Distance)
                    {
                        curSearchNodeNeighbor.Distance = distance;
                        curSearchNodeNeighbor.Previous = curSearchNode;
                        searchList.Reposition(curSearchNodeNeighbor);
                    }
                }
            }
        }

        EventManager.AddPathFoundInvoker(this);
        EventManager.AddPathTraversalCompleteInvoker(this);

        SetTarget(ConvertPathToString(curSearchNode).First);
    }
        public void RemoveShouldNotUpdateCountWhenNotFound()
        {
            SortedLinkedList <int> list = new SortedLinkedList <int>();

            list.Add(1);

            Assert.IsFalse(list.Remove(2), "Remove should return false on failure");
            Assert.AreEqual(1, list.Count, "Remove shoud not decrement count on failure");
        }
        public void AddSingleElementToEmptyList()
        {
            int element = 34;
            var list    = new SortedLinkedList <int>(compareLogic_Ascending);

            list.Add(element);

            Assert.Equal(list.Count, 1);
            Assert.Equal(list.First.Value, element);
        }
        public void SearchShouldReturnNullWhenNotFound()
        {
            SortedLinkedList <int> list = new SortedLinkedList <int>();

            list.Add(1);

            DoubleLinkedNode <int> actual = list.Search(2);

            Assert.IsNull(actual, "Search should return null result when value does not exist in the list");
        }
        public void SearchShouldReturnNonNullWhenFound()
        {
            SortedLinkedList <int> list = new SortedLinkedList <int>();

            list.Add(1);

            DoubleLinkedNode <int> actual = list.Search(1);

            Assert.IsNotNull(actual, "Search should return non-null result when value exists in the list");
            Assert.AreEqual(1, actual.Value, "Search should return the correct value when it exists in the list");
        }
        public void AddMultipleElementsToList_OrderedAscending_SortedAscending()
        {
            int[] ordered = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            var   list    = new SortedLinkedList <int>(compareLogic_Ascending);

            foreach (int i in ordered)
            {
                list.Add(i);
            }

            Assert.Equal(list.Count, ordered.Length);
            Assert.Equal(list.ToArray(), ordered);
        }
Example #21
0
        public void Put(string value)
        {
            int hash = HashFunction.Hash(value);

            if (string.IsNullOrEmpty(_table[hash]))
            {
                _table[hash] = value;
            }
            else
            {
                _sll.Add(value);
            }
        }
Example #22
0
        public void InsertFirstItemToList()
        {
            //Arrange
            int valueToInsert = 5;
            var list          = new SortedLinkedList();

            //Act
            list.Add(valueToInsert);

            //Assert
            Assert.Equal(valueToInsert, list.Head.Value);
            Assert.Null(list.Head.Next);
        }
        public void TestMethod1()
        {
            var list = new SortedLinkedList <int>();

            list.Add(5);
            list.Add(1);
            list.Add(3);
            list.Add(6);
            list.Add(10);
            list.Add(3);
            list.Add(5);
        }
Example #24
0
        public void InsertMultipleItemsToList(int count)
        {
            //Arrange
            var list = new SortedLinkedList();

            //Act
            for (int i = 0; i < count; i++)
            {
                list.Add(i);
            }

            //Assert
            Assert.Equal(count, GetLength(list));
        }
        public void AddMultipleElementsToList_Unordered_SortedAscending()
        {
            int[] unordered = new int[] { 5, 9, 1, 6, 4, 7, 2, 3, 8, 10 };
            var   list      = new SortedLinkedList <int>(compareLogic_Ascending);

            foreach (int i in unordered)
            {
                list.Add(i);
            }

            Array.Sort(unordered);

            Assert.Equal(list.Count, unordered.Length);
            Assert.Equal(list.ToArray(), unordered);
        }
        public void AddMultipleElementsToList_Unordered_SortedDescending_NegativeValues()
        {
            int[] unordered = new int[] { 5, 9, -1, 6, 4, 10, -7, 2, 3, 8 };
            var   list      = new SortedLinkedList <int>(compareLogic_Descending);

            foreach (int i in unordered)
            {
                list.Add(i);
                System.Diagnostics.Debug.WriteLine($"Added element: {i}.");
            }

            Array.Sort(unordered, (a, b) => b.CompareTo(a));

            Assert.Equal(list.Count, unordered.Length);
            Assert.Equal(list.ToArray(), unordered);
        }
Example #27
0
    private LinkedList <Waypoint> doDijkstraSearch()
    {
        Graph <Waypoint> graph = GraphBuilder.Graph;

        //Create a search list (a sorted linked list) of search nodes (I provided a SearchNode class, which you should instantiate with Waypoint. I also provided a SortedLinkedList class)
        SortedLinkedList <SearchNode <Waypoint> > searchList = new SortedLinkedList <SearchNode <Waypoint> >();

        //Create a dictionary of search nodes keyed by the corresponding graph node.This dictionary gives us a very fast way to determine if the search node corresponding to a graph node is still in the search list
        Dictionary <GraphNode <Waypoint>, SearchNode <Waypoint> > searchNodeMap = new Dictionary <GraphNode <Waypoint>, SearchNode <Waypoint> >();

        //Save references to the start and end graph nodes in variables
        start = GraphBuilder.Start;
        end   = GraphBuilder.End;

        GraphNode <Waypoint> startGraphNode = graph.Find(start);
        GraphNode <Waypoint> endGraphNode   = graph.Find(end);

        //For each graph node in the graph
        foreach (GraphNode <Waypoint> graphNode in graph.Nodes)
        {
            //Create a search node for the graph node (the constructor I provided in the SearchNode class initializes distance to the max float value and previous to null)
            SearchNode <Waypoint> searchNode = new SearchNode <Waypoint>(graphNode);

            //If the graph node is the start node
            if (graphNode == startGraphNode)
            {
                // Set the distance for the search node to 0
                searchNode.Distance = 0;
            }

            //Add the search node to the search list
            searchList.Add(searchNode);
            //Add the search node to the dictionary keyed by the graph node
            searchNodeMap.Add(graphNode, searchNode);
        }

        //While the search list isn't empty
        while (searchList.Count > 0)
        {
            //Save a reference to the current search node(the first search node in the search list) in a variable
            SearchNode <Waypoint> currentSearchNode = searchList.First.Value;
            //Remove the first search node from the search list
            searchList.RemoveFirst();
            //Save a reference to the current graph node for the current search node in a variable
            GraphNode <Waypoint> currentGraphNode = currentSearchNode.GraphNode;
            //Remove the search node from the dictionary(because it's no longer in the search list)
            searchNodeMap.Remove(currentGraphNode);

            //If the current graph node is the end node
            if (currentGraphNode == endGraphNode)
            {
                //Display the distance for the current search node as the path length in the scene(Hint: I used the HUD and the event system to do this)
                pathFoundEvent.Invoke(currentSearchNode.Distance);

                //Return a linked list of the waypoints from the start node to the end node(Hint: The lecture code for the Searching a Graph lecture builds a linked list for a path in the ConvertPathToString method)
                LinkedList <Waypoint> pathLinkedList = new LinkedList <Waypoint>();
                while (currentSearchNode != null)
                {
                    GraphNode <Waypoint> graphNode = currentSearchNode.GraphNode;
                    Waypoint             waypoint  = graphNode.Value;
                    pathLinkedList.AddFirst(waypoint);
                    currentSearchNode = currentSearchNode.Previous;
                }
                return(pathLinkedList);
            }

            //For each of the current graph node's neighbors
            foreach (GraphNode <Waypoint> neighbour in currentGraphNode.Neighbors)
            {
                //If the neighbor is still in the search list(use the dictionary to check this)
                SearchNode <Waypoint> neighbourSearchNode = null;
                if (searchNodeMap.TryGetValue(neighbour, out neighbourSearchNode))
                {
                    //Save the distance for the current graph node + the weight of the edge from the current graph node to the current neighbor in a variable
                    float distanceToStart = currentSearchNode.Distance + currentGraphNode.GetEdgeWeight(neighbour);
                    //If the distance you just calculated is less than the current distance for the neighbor search node(Hint: You can retrieve the neighbor search node from the dictionary using the neighbor graph node)
                    if (distanceToStart < neighbourSearchNode.Distance)
                    {
                        //Set the distance for the neighbor search node to the new distance
                        neighbourSearchNode.Distance = distanceToStart;
                        //Set the previous node for the neighbor search node to the current search node
                        neighbourSearchNode.Previous = currentSearchNode;
                        //Tell the search list to Reposition the neighbor search node. We need to do this because the change to the distance for the neighbor search node could have moved it forward in the search list
                        searchList.Reposition(neighbourSearchNode);
                    }
                }
            }
        }

        return(null);
    }
    LinkedList <SearchNode <Waypoint> > Search()
    {
        SortedLinkedList <SearchNode <Waypoint> > searchList = new SortedLinkedList <SearchNode <Waypoint> >();
        Dictionary <SearchNode <Waypoint>, GraphNode <Waypoint> > searchDictionary = new Dictionary <SearchNode <Waypoint>, GraphNode <Waypoint> >();
        LinkedList <SearchNode <Waypoint> > pathNodes = new LinkedList <SearchNode <Waypoint> >();

        Waypoint start = GameObject.FindGameObjectWithTag("Start").GetComponent <Waypoint>();
        Waypoint end   = GameObject.FindGameObjectWithTag("End").GetComponent <Waypoint>();

        for (int i = 0; i < GraphBuilder.Graph.Count; i++)
        {
            GraphNode <Waypoint>  node       = GraphBuilder.Graph.Nodes[i];
            SearchNode <Waypoint> searchNode = new SearchNode <Waypoint>(node);


            if (node.Value.Equals(start))
            {
                searchNode.Distance = 0;
            }

            searchList.Add(searchNode);
            searchDictionary.Add(searchNode, node);
        }

        while (searchList.Count != 0)
        {
            SearchNode <Waypoint> currentSearchNode = searchList.First.Value;
            searchList.Remove(currentSearchNode);

            GraphNode <Waypoint> currentGraphNode = searchDictionary[currentSearchNode];
            searchDictionary.Remove(currentSearchNode);

            if (currentGraphNode.Value.Equals(end))
            {
                pathFoundEvent.Invoke(currentSearchNode.Distance);

                pathNodes.AddFirst(currentSearchNode);
                SearchNode <Waypoint> previous = currentSearchNode.Previous;

                while (previous != null)
                {
                    pathNodes.AddFirst(previous);
                    previous = previous.Previous;
                }

                return(pathNodes);
            }

            foreach (var neighbor in currentGraphNode.Neighbors)
            {
                if (searchDictionary.ContainsValue(neighbor))
                {
                    float newDistance = currentSearchNode.Distance + currentGraphNode.GetEdgeWeight(neighbor);

                    SearchNode <Waypoint> neighborSearchNode = searchDictionary.FirstOrDefault(x => x.Value.Equals(neighbor)).Key;


                    if (newDistance < neighborSearchNode.Distance)
                    {
                        neighborSearchNode.Distance = newDistance;
                        neighborSearchNode.Previous = currentSearchNode;
                        searchList.Reposition(neighborSearchNode);
                    }
                }
            }
        }

        Debug.Log("WI");
        return(pathNodes);
    }
    LinkedList <Waypoint> Search(Waypoint _start, Waypoint _goal, Graph <Waypoint> _graph)
    {
        SortedLinkedList <SearchNode <Waypoint> > searchList = new SortedLinkedList <SearchNode <Waypoint> >();
        Dictionary <GraphNode <Waypoint>, SearchNode <Waypoint> > searchNodesDictionary =
            new Dictionary <GraphNode <Waypoint>, SearchNode <Waypoint> >();

        GraphNode <Waypoint> startNode = _graph.Find(_start);
        GraphNode <Waypoint> endNode   = _graph.Find(_goal);

        // SearchNode<Waypoint> searchNode = new SearchNode<Waypoint>(startNode);

        // searchList.AddFirst(searchNode);
        // wayPointDictionary.Add(startNode,searchNode);


        //We add elements to search list, and search dictionary,
        //if the node is startNode, set the distance to 0
        foreach (GraphNode <Waypoint> node in _graph.Nodes)
        {
            SearchNode <Waypoint> temp = new SearchNode <Waypoint>(node);
            print("Checking previous " + temp.Previous);
            if (node == startNode)
            {
                temp.Distance = 0;
            }
            searchList.Add(temp);
            searchNodesDictionary.Add(node, temp);
            // print("Key: "+node.Value.Id+" Value: "+temp.GraphNode.Value.Id);
        }

        //Initial Checking

        // for (int i = 0; i < searchNodesDictionary.Count; i++)
        // {
        //  GraphNode<Waypoint> node = searchNodesDictionary.ElementAt(i).Key;
        //  SearchNode<Waypoint> temp;
        //  if (searchNodesDictionary.TryGetValue(node, out temp))
        //  {
        //   print(i+" - ID: "+temp.GraphNode.Value.Id+" Graph Node: "+temp.GraphNode.Value);
        //  }
        // }

        //While search list is not empty (>0)
        //
        while (searchList.Count > 0)
        {
            //Instructions 1
            SearchNode <Waypoint> currentSearchNode = searchList.First.Value;
            // SearchNode<Waypoint> currentSearchNode = searchList.Last.Value;
            //Start Node is current search node
            print("Current Node: " + currentSearchNode.GraphNode.Value + " - ID: " + currentSearchNode.GraphNode.Value.Id);
            searchList.RemoveFirst();
            GraphNode <Waypoint> currentGraphNode = currentSearchNode.GraphNode;
            // searchNodesDictionary.Remove(currentGraphNode);

            // for (int i = 0; i < searchNodesDictionary.Count; i++)
            // {
            //  GraphNode<Waypoint> node = searchNodesDictionary.ElementAt(i).Key;
            //  SearchNode<Waypoint> temp;
            //  if (searchNodesDictionary.TryGetValue(node, out temp))
            //  {
            //   print(i+" - ID: "+temp.GraphNode.Value.Id+" Graph Node: "+temp.GraphNode.Value);
            //  }
            // }



            if (currentGraphNode.Equals(endNode))
            {
                pathFoundEvent.Invoke(currentSearchNode.Distance);

                LinkedList <Waypoint> returnList = ConvertPathToLinkedList(endNode, searchNodesDictionary);
                // searchNodesDictionary.Remove(currentGraphNode);
                return(returnList);
            }

            foreach (GraphNode <Waypoint> neighbor in currentGraphNode.Neighbors)
            {
                SearchNode <Waypoint> _temp;
                if (searchNodesDictionary.TryGetValue(neighbor, out _temp))
                {
                    // print("4.1 ");
                    float dist = _temp.Distance + currentGraphNode.GetEdgeWeight(neighbor);
                    if (dist < _temp.Distance)
                    {
                        _temp.Distance = dist;
                        _temp.Previous = currentSearchNode;
                        searchList.Reposition(_temp);
                        print("4.2 ");
                    }
                }
            }
        }

        return(null);
    }
Example #30
0
        /// <summary>
        /// Tests the SortedLinkedList and Traveler classes
        /// </summary>
        /// <param name="args">command-line args</param>
        static void Main(string[] args)
        {
            // Graph test objects
            Graph <Waypoint> correctSmallGraph;
            Graph <Waypoint> correctMediumGraph;
            Graph <Waypoint> correctLargeGraph;

            // SearchNode test objects
            SearchNode <Waypoint> searchNode;

            // SortedLinkedList test objects
            SortedLinkedList <SearchNode <Waypoint> > testList =
                new SortedLinkedList <SearchNode <Waypoint> >();

            // GraphBuilder test object
            GraphBuilder graphBuilder;

            // Traveler test object
            Traveler traveler;

            // set up UnityEngine delegates
            GameObject.AddGetComponentDelegate(typeof(Waypoint), GetWaypointComponent);
            GameObject.AddFindObjectByTagDelegate(FindGameObjectWithTag);
            GameObject.AddFindObjectsByTagDelegate(FindGameObjectsWithTag);

            // correct graphs
            correctSmallGraph  = GraphUtils.GetCorrectGraph(GraphSize.Small);
            correctMediumGraph = GraphUtils.GetCorrectGraph(GraphSize.Medium);
            correctLargeGraph  = GraphUtils.GetCorrectGraph(GraphSize.Large);

            // loop while there's more input
            string input = Console.ReadLine();

            while (input[0] != 'q')
            {
                // extract test case number from string
                GetInputValueFromString(input);

                // execute selected test case
                switch (testCaseNumber)
                {
                case 1:
                    // test SortedLinkedList Add method with single node
                    testList.Clear();
                    testList.Add(SearchNodeUtils.GetSearchNode(Vector3.zero, 1, 0));
                    if (testList.Count == 1 &&
                        ListContentsEqual(testList, "0"))
                    {
                        Console.WriteLine("Passed");
                    }
                    else
                    {
                        Console.WriteLine("FAILED");
                    }
                    break;

                case 2:
                    // test SortedLinkedList Add method with two equal nodes
                    // (comparison is based on distance of search nodes)
                    testList.Clear();
                    testList.Add(SearchNodeUtils.GetSearchNode(Vector3.zero, 1, 0));
                    testList.Add(SearchNodeUtils.GetSearchNode(Vector3.zero, 2, 0));
                    if (testList.Count == 2 &&
                        ListContentsEqual(testList, "0c0"))
                    {
                        Console.WriteLine("Passed");
                    }
                    else
                    {
                        Console.WriteLine("FAILED");
                    }
                    break;

                case 3:
                    // test SortedLinkedList Add method with multiple unequal nodes
                    // (comparison is based on distance of search nodes)
                    testList.Clear();
                    testList.Add(SearchNodeUtils.GetSearchNode(Vector3.zero, 1, 1));
                    testList.Add(SearchNodeUtils.GetSearchNode(Vector3.zero, 2, 0));
                    testList.Add(SearchNodeUtils.GetSearchNode(Vector3.zero, 3, 2));
                    if (testList.Count == 3 &&
                        ListContentsEqual(testList, "0c1c2"))
                    {
                        Console.WriteLine("Passed");
                    }
                    else
                    {
                        Console.WriteLine("FAILED");
                    }
                    break;

                case 4:
                    // test SortedLinkedList Reposition method with
                    // no change in position
                    // (comparison is based on distance of search nodes)
                    testList.Clear();
                    testList.Add(SearchNodeUtils.GetSearchNode(Vector3.zero, 1, 1));
                    testList.Add(SearchNodeUtils.GetSearchNode(Vector3.zero, 2, 0));
                    searchNode = SearchNodeUtils.GetSearchNode(Vector3.zero, 3, 2);
                    testList.Add(searchNode);
                    testList.Reposition(searchNode);
                    if (testList.Count == 3 &&
                        ListContentsEqual(testList, "0c1c2"))
                    {
                        Console.WriteLine("Passed");
                    }
                    else
                    {
                        Console.WriteLine("FAILED");
                    }
                    break;

                case 5:
                    // test SortedLinkedList Reposition method with
                    // change in position
                    // (comparison is based on distance of search nodes)
                    testList.Clear();
                    testList.Add(SearchNodeUtils.GetSearchNode(Vector3.zero, 1, 1));
                    testList.Add(SearchNodeUtils.GetSearchNode(Vector3.zero, 2, 0));
                    searchNode = SearchNodeUtils.GetSearchNode(Vector3.zero, 3, 2);
                    testList.Add(searchNode);
                    searchNode.Distance = 0.5f;
                    testList.Reposition(searchNode);
                    if (testList.Count == 3 &&
                        ListContentsEqual(testList, "0c0.5c1"))
                    {
                        Console.WriteLine("Passed");
                    }
                    else
                    {
                        Console.WriteLine("FAILED");
                    }
                    break;

                case 6:
                    // test GraphBuilder class for small graph
                    currentSize = GraphSize.Small;
                    BuildGameObjectIdWaypointDictionary(currentSize);
                    graphBuilder = new GraphBuilder(new GameObject(int.MaxValue,
                                                                   new Transform(Vector3.zero)));
                    graphBuilder.Awake();
                    if (GraphUtils.WaypointGraphsEqual(correctSmallGraph,
                                                       GraphBuilder.Graph))
                    {
                        Console.WriteLine("Passed");
                    }
                    else
                    {
                        Console.WriteLine("FAILED");
                    }
                    break;

                case 7:
                    // test GraphBuilder class for large graph
                    currentSize = GraphSize.Large;
                    BuildGameObjectIdWaypointDictionary(currentSize);
                    graphBuilder = new GraphBuilder(new GameObject(int.MaxValue,
                                                                   new Transform(Vector3.zero)));
                    graphBuilder.Awake();
                    if (GraphUtils.WaypointGraphsEqual(correctLargeGraph,
                                                       GraphBuilder.Graph))
                    {
                        Console.WriteLine("Passed");
                    }
                    else
                    {
                        Console.WriteLine("FAILED");
                    }
                    break;

                case 8:
                    // test Traveler class for small graph
                    currentSize = GraphSize.Small;
                    BuildGameObjectIdWaypointDictionary(currentSize);
                    GraphBuilder.Graph = correctSmallGraph;
                    traveler           = new Traveler(new GameObject(int.MaxValue,
                                                                     new Transform(Vector3.zero)));
                    traveler.Start();
                    if (WithinOneHundredth(traveler.PathLength, 9))
                    {
                        Console.WriteLine("Passed");
                    }
                    else
                    {
                        Console.WriteLine("FAILED");
                    }
                    break;

                case 9:
                    // test Traveler class for medium graph
                    currentSize = GraphSize.Medium;
                    BuildGameObjectIdWaypointDictionary(currentSize);
                    GraphBuilder.Graph = correctMediumGraph;
                    traveler           = new Traveler(new GameObject(int.MaxValue,
                                                                     new Transform(Vector3.zero)));
                    traveler.Start();
                    if (WithinOneHundredth(traveler.PathLength, 18.0111f))
                    {
                        Console.WriteLine("Passed");
                    }
                    else
                    {
                        Console.WriteLine("FAILED");
                    }
                    break;

                case 10:
                    // test Traveler class for large graph
                    currentSize = GraphSize.Large;
                    BuildGameObjectIdWaypointDictionary(currentSize);
                    GraphBuilder.Graph = correctLargeGraph;
                    traveler           = new Traveler(new GameObject(int.MaxValue,
                                                                     new Transform(Vector3.zero)));
                    traveler.Start();
                    if (WithinOneHundredth(traveler.PathLength, 19.4451f))
                    {
                        Console.WriteLine("Passed");
                    }
                    else
                    {
                        Console.WriteLine("FAILED");
                    }
                    break;

                    /*
                     * // The following cases were for testing the ListContentsEqual
                     * // method and are never run by the autograder
                     * case 11:
                     * // testing ListContentsEqual method
                     * // empty sorted list
                     * testList = new SortedLinkedList<SearchNode<Waypoint>>();
                     * Console.WriteLine(ListContentsEqual(testList, ""));
                     * break;
                     * case 12:
                     * // testing ListContentsEqual method
                     * // 2 more elements in sorted list than expected
                     * testList = new SortedLinkedList<SearchNode<Waypoint>>();
                     * testList.Add(GetSearchNode(Vector3.zero,0,0));
                     * testList.Add(GetSearchNode(Vector3.zero, 0, 0));
                     * testList.Add(GetSearchNode(Vector3.zero, 0, 0));
                     * Console.WriteLine(ListContentsEqual(testList, "0"));
                     * break;
                     * case 13:
                     * // testing ListContentsEqual method
                     * // 1 more element in sorted list than expected
                     * testList = new SortedLinkedList<SearchNode<Waypoint>>();
                     * testList.Add(GetSearchNode(Vector3.zero, 0, 0));
                     * testList.Add(GetSearchNode(Vector3.zero, 0, 0));
                     * testList.Add(GetSearchNode(Vector3.zero, 0, 0));
                     * Console.WriteLine(ListContentsEqual(testList, "0,0"));
                     * break;
                     * case 14:
                     * // testing ListContentsEqual method
                     * // fewer elements in sorted list than expected
                     * testList = new SortedLinkedList<SearchNode<Waypoint>>();
                     * testList.Add(GetSearchNode(Vector3.zero, 0, 0));
                     * Console.WriteLine(ListContentsEqual(testList, "0,0"));
                     * break;
                     */
                }

                input = Console.ReadLine();
            }
        }