public void GetNodesCollectionTest(string expected, int index) { 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)); var nodeList = graph.GetNodes(); Assert.Equal(expected, nodeList[index].Value); }
public void GetNodesTestNull() { Graph.Classes.Graph graph = new Graph.Classes.Graph(); var nodes = graph.GetNodes(); Assert.Empty(nodes); }
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(); }
public void GetAllNodes(object one, object two, object three) { List <object> listTest = new List <object>(); listTest.Add(one); listTest.Add(two); listTest.Add(three); Graph.Classes.Graph graphTest = new Graph.Classes.Graph(listTest); List <Vertex> vertices = graphTest.GetNodes(); //Assert.Equal(graphTest.GetNodes()[two].Value, one); Assert.True(listTest[0] == vertices[0].Value && listTest[1] == vertices[1].Value && listTest[2] == vertices[2].Value); }