예제 #1
0
        public void SmallGraph_EdgesOfAbsentVertexTest()
        {
            var graph = new AdjacencyListGraph <int>();

            graph.AddEdge(1, 2);
            graph.AddEdge(1, 3);
            graph.AddEdge(1, 4);
            graph.AddEdge(2, 3);
            graph.AddEdge(3, 4);

            var edges = graph.EdgesOf(5);
        }
예제 #2
0
        public void SmallGraph_EdgesOfTest()
        {
            var graph = new AdjacencyListGraph <int>();

            graph.AddEdge(1, 2);
            graph.AddEdge(1, 3);
            graph.AddEdge(1, 4);
            graph.AddEdge(2, 3);
            graph.AddEdge(3, 4);

            int idx     = 0;
            var targets = new[] { 2, 3, 4 };

            foreach (var edge in graph.EdgesOf(1))
            {
                Assert.AreEqual(1, edge.Source);
                Assert.AreEqual(targets[idx], edge.Target);
                idx++;
            }
            Assert.AreEqual(3, idx);
        }