Beispiel #1
0
        public void CollectionOfAllNodesCanBeRetrieve()
        {
            MyGraph <int>      graph         = new MyGraph <int>();
            Node <int>         nodeA         = graph.AddNode(5);
            Node <int>         nodeB         = graph.AddNode(10);
            Node <int>         nodeC         = graph.AddNode(1);
            Node <int>         nodeD         = graph.AddNode(99);
            List <Node <int> > expectedNodes = new List <Node <int> > {
                nodeA, nodeB, nodeC, nodeD
            };

            List <Node <int> > actualNodes = graph.GetNodes();

            Assert.Equal(expectedNodes, actualNodes);
        }
Beispiel #2
0
        public void GraphWithOnlyOneNodeAndOneEdgeCanBeRetrieved()
        {
            MyGraph <int> graph = new MyGraph <int>();
            Node <int>    nodeA = graph.AddNode(5);

            List <Node <int> > expectedNodes = new List <Node <int> >()
            {
                nodeA
            };

            graph.AddDirectedEdge(nodeA, nodeA, 5);

            List <Node <int> > actualNodes = graph.GetNodes();

            Assert.Equal(expectedNodes, actualNodes);
        }
Beispiel #3
0
        public void ReturnsNullIfGraphEmpty()
        {
            MyGraph <int> graph = new MyGraph <int>();

            Assert.Null(graph.GetNodes());
        }