Exemplo n.º 1
0
            public void TestInsertEdge()
            {
                object attr;
                Graph  gr     = new Graph();
                int    idFrom = gr.InsertNode(0);
                int    idTo   = gr.InsertNode(1);

                gr.InsertEdge(idFrom, idTo, 100);
                Assert.AreEqual(gr.OutEdgeCount(idFrom), 1);
                Assert.AreEqual(gr.OutEdgeCount(idTo), 0);
                int idEdge = gr.GetOutEdge(idFrom, 0, out attr);

                Assert.AreEqual(100, (int)attr);
                Assert.AreEqual(idTo, idEdge);

                // Try inserting the same edge twice to trigger exception...
                gr.InsertEdge(0, 1, 200);
            }
Exemplo n.º 2
0
        public void TestInsertEdge()
        {
            object attr;
            var    gr     = new Graph();
            var    idFrom = gr.InsertVertex(0);
            var    idTo   = gr.InsertVertex(1);

            gr.AddEdge(idFrom, idTo, 100);
            Assert.AreEqual(gr.OutEdgeCount(idFrom), 1);
            Assert.AreEqual(gr.OutEdgeCount(idTo), 0);
            var idEdge = gr.GetOutEdge(idFrom, 0, out attr);

            Assert.AreEqual(100, (int)attr);
            Assert.AreEqual(idTo, idEdge);

            // Try inserting the same edge twice to trigger exception...
            Assert.Throws(typeof(VfException), () => gr.AddEdge(0, 1, 200));
        }