public void GetSizeEmpty()
        {
            List <object> listTest = new List <object>();

            Graph.Classes.Graph graph = new Graph.Classes.Graph(listTest);
            graph.Size();

            Assert.Equal(0, graph.Size());
        }
        public void GetSizeTwo()
        {
            List <object> listTest = new List <object>();

            listTest.Add("Dog");
            Graph.Classes.Graph graph = new Graph.Classes.Graph(listTest);
            graph.Size();

            Assert.Equal(1, graph.Size());
        }
        public void GetSizeOne()
        {
            List <object> listTest = new List <object>();

            Graph.Classes.Graph graph = new Graph.Classes.Graph(listTest);
            graph.AddEdge("Apple", "Banana", 10);
            graph.Size();

            Assert.Equal(2, graph.Size());
        }
        public void GetSizeThree()
        {
            List <object> listTest = new List <object>();

            listTest.Add("Dog");
            listTest.Add("Cat");
            listTest.Add("Chocolate");
            listTest.Add("Banana");
            Graph.Classes.Graph graph = new Graph.Classes.Graph(listTest);
            graph.AddEdge("Peach", "Orange", 10);
            graph.Size();

            Assert.Equal(6, graph.Size());
        }
        public void SizeTest()
        {
            Graph.Classes.Graph graph = new Graph.Classes.Graph();
            Node parent = new Node();

            parent.Value = "A";

            LinkedList <Tuple <Node, int> > originList = new LinkedList <Tuple <Node, int> >();
            Tuple <Node, int> origin = new Tuple <Node, int>(parent, 0);

            originList.AddFirst(origin);

            graph.AdjacencyList.AddFirst(originList);

            Node child = new Node();

            child.Value = "B";

            graph.AddEdge(parent, new Tuple <Node, int>(child, 5));

            Node c = new Node();

            c.Value = "C";

            graph.AddEdge(parent, new Tuple <Node, int>(c, 4));

            int count = graph.Size();

            Assert.Equal(3, count);
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Graphs");
            Console.WriteLine("");

            List <object> listTest = new List <object>();

            listTest.Add("soloNode");
            Graph.Classes.Graph graph = new Graph.Classes.Graph(listTest);
            graph.AddEdge("Apple", "Banana", 10);
            graph.AddEdge("Dog", "Cat", 22);
            graph.AddEdge("xBox", "PlayStation", 7);
            Console.WriteLine("Creating a new graph with 7 nodes and 3 edges");
            Console.WriteLine($"Return size of graph:  {graph.Size()}");

            Dictionary <object, int> toNeighbor   = graph.GetNeighbors("Dog");
            Dictionary <object, int> fromNeighbor = graph.GetNeighbors("xBox");

            //Console.WriteLine($"Return neighbor of graph from Dog node:");
            foreach (var item in toNeighbor.Values)
            {
                //Console.WriteLine(item);
            }

            Console.WriteLine("Return all vertices in the graph:  ");
            foreach (var item in graph.Vertices)
            {
                Console.WriteLine(item.Value);
            }

            Console.ReadLine();
        }
        public void NullSizeTest()
        {
            Graph.Classes.Graph graph = new Graph.Classes.Graph();

            int count = graph.Size();

            Assert.Equal(0, count);
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Graph.Classes.Graph graph = new Graph.Classes.Graph();
            Node parent = new Node();

            parent.Value = "A";

            LinkedList <Tuple <Node, int> > originList = new LinkedList <Tuple <Node, int> >();
            Tuple <Node, int> origin = new Tuple <Node, int>(parent, 0);

            originList.AddFirst(origin);

            graph.AdjacencyList.AddFirst(originList);

            Node child = new Node();

            child.Value = "B";

            graph.AddEdge(parent, new Tuple <Node, int>(child, 5));

            Node c = new Node();

            c.Value = "C";

            graph.AddEdge(parent, new Tuple <Node, int>(c, 4));


            foreach (var item in graph.AdjacencyList)
            {
                foreach (var node in item)
                {
                    Console.Write(node.Item2);
                    Console.WriteLine(node.Item1.Value);
                }
            }

            var nodeList = graph.GetNodes();

            foreach (var item in nodeList)
            {
                Console.Write(item.Value);
            }

            var neighbor = graph.GetNeighbors(parent);

            foreach (var item in neighbor)
            {
                Console.Write(item.Item1.Value);
                Console.WriteLine(item.Item2);
            }

            var count = graph.Size();

            Console.WriteLine(count);
            Console.ReadKey();
        }
 /// <summary>
 /// Finds whether a given route is possible in the given graph, and returns a tuple with that route's cost.
 /// </summary>
 /// <param name="graph">
 /// Graph<string, int>: the graph the route potentially exists within
 /// </param>
 /// <param name="route">
 /// string[]: the route we are looking for within the graph
 /// </param>
 /// <returns>
 /// Tuple<bool, int>: a tuple containing whether the route is possible (bool), and if it is, its cost (int). If the route is not possible, returns -1 for the cost
 /// </returns>
 public static Tuple <bool, int> GetEdges(this Graph <string, int> graph, string[] route)
 {
     if (route.Length == 0 && graph.Size() > 0)
     {
         return(Tuple.Create(true, 0));
     }
     else
     {
         var vertices = graph.AdjList.Keys;
         foreach (Vertex <string> oneVertex in vertices)
         {
             var result = GetEdges(graph, new List <Vertex <string> >(), oneVertex, route, 0, 0);
             if (result.Item1)
             {
                 return(result);
             }
         }
         return(Tuple.Create(false, -1));
     }
 }
        public void SizeTestLarge()
        {
            Graph.Classes.Graph graph = new Graph.Classes.Graph();
            Node parent = new Node();

            parent.Value = "A";

            LinkedList <Tuple <Node, int> > originList = new LinkedList <Tuple <Node, int> >();
            Tuple <Node, int> origin = new Tuple <Node, int>(parent, 0);

            originList.AddFirst(origin);

            graph.AdjacencyList.AddFirst(originList);

            Node child = new Node();

            child.Value = "B";

            graph.AddEdge(parent, new Tuple <Node, int>(child, 5));

            Node c = new Node();

            c.Value = "C";

            Node d = new Node();

            d.Value = "D";

            Node e = new Node();

            e.Value = "E";

            Node f = new Node();

            f.Value = "F";

            Node g = new Node();

            g.Value = "G";

            Node h = new Node();

            h.Value = "H";

            Node i = new Node();

            i.Value = "I";

            Node j = new Node();

            j.Value = "J";

            graph.AddEdge(parent, new Tuple <Node, int>(c, 4));
            graph.AddEdge(parent, new Tuple <Node, int>(d, 4));
            graph.AddEdge(parent, new Tuple <Node, int>(e, 4));
            graph.AddEdge(parent, new Tuple <Node, int>(f, 4));
            graph.AddEdge(parent, new Tuple <Node, int>(g, 4));
            graph.AddEdge(parent, new Tuple <Node, int>(h, 4));
            graph.AddEdge(parent, new Tuple <Node, int>(i, 4));
            graph.AddEdge(parent, new Tuple <Node, int>(j, 4));

            int count = graph.Size();

            Assert.Equal(10, count);
        }