public void DetectsNonExistingNodes() { EdgeListGraph <int> graph = new EdgeListGraph <int>(); EdgeListNode <int> node1 = new EdgeListNode <int>(1); EdgeListNode <int> node2 = new EdgeListNode <int>(2); EdgeListNode <int> node3 = new EdgeListNode <int>(3); node2.AddEdgeTo(node3); graph.AddNode(node1); graph.AddNode(node2); bool result; //by value result = graph.ContainsNode(12); Assert.False(result); //by node result = graph.ContainsNode(new EdgeListNode <int>(12)); Assert.False(result); //by predicate result = graph.ContainsNode(node => node.Value >= 12); Assert.False(result); }
public void DetectsExistingNodes() { EdgeListGraph <int> graph = new EdgeListGraph <int>(); EdgeListNode <int> node1 = new EdgeListNode <int>(1); EdgeListNode <int> node2 = new EdgeListNode <int>(2); EdgeListNode <int> node3 = new EdgeListNode <int>(3); node2.AddEdgeTo(node3); graph.AddNode(node1); graph.AddNode(node2); bool result1, result2, result3; //by value result1 = graph.ContainsNode(1); result2 = graph.ContainsNode(2); result3 = graph.ContainsNode(3); Assert.True(result1); Assert.True(result2); Assert.True(result3); //by node result1 = graph.ContainsNode(node1); result2 = graph.ContainsNode(node2); result3 = graph.ContainsNode(node3); Assert.True(result1); Assert.True(result2); Assert.True(result3); //by predicate result1 = graph.ContainsNode(node => node.Value < 2); result2 = graph.ContainsNode(node => Math.Pow(node.Value, 2) == 4); result3 = graph.ContainsNode(node => node.Value > 2); Assert.True(result1); Assert.True(result2); Assert.True(result3); }