Example #1
0
        public void TestRemoveEdgeById()
        {
            var graph = new DirectedDynamicGraph();

            var id = graph.AddEdge(1, 2, 0102, 010200);

            graph.AddEdge(1, 3, 0103);

            Assert.AreEqual(1, graph.RemoveEdgeById(1, id));

            Assert.AreEqual(1, graph.EdgeCount);
            var enumerator = graph.GetEdgeEnumerator();

            Assert.IsTrue(enumerator.MoveTo(1));
            Assert.IsTrue(enumerator.MoveNext());
            Assert.AreEqual(3, enumerator.Neighbour);
            Assert.AreEqual(0103, enumerator.Data0);

            graph = new DirectedDynamicGraph();
            graph.AddEdge(1, 2, 0102, 010200);
            id = graph.AddEdge(1, 3, 0103);
            graph.AddEdge(1, 4, 0104, 010400, 01040000);

            Assert.AreEqual(1, graph.RemoveEdgeById(1, id));
            enumerator = graph.GetEdgeEnumerator();
            Assert.IsTrue(enumerator.MoveTo(1));
            Assert.IsTrue(enumerator.MoveNext());
            Assert.AreEqual(2, enumerator.Neighbour);
            Assert.AreEqual(0102, enumerator.Data0);
            Assert.AreEqual(010200, enumerator.DynamicData[0]);
            Assert.IsTrue(enumerator.MoveNext());
            Assert.AreEqual(4, enumerator.Neighbour);
            Assert.AreEqual(0104, enumerator.Data0);
            Assert.AreEqual(010400, enumerator.DynamicData[0]);
            Assert.AreEqual(01040000, enumerator.DynamicData[1]);
        }