public void GraphWithVertexEdgePropertiesTest()
        {
            var graph = new AdjacencyListGraph <int, int>();
            var v0    = new Vertex(0, 0);
            var v1    = graph.AddVertex(new Vertex(1, 1));

            graph.AddVertex(v0);
            Assert.AreEqual(default(int), graph.GetVertexProp(v0));
            graph.SetVertexProp(v0, 1);
            Assert.AreEqual(1, graph.GetVertexProp(v0));

            Assert.AreEqual(default(int), graph.GetVertexProp(v1));
            graph.SetVertexProp(v1, -5);
            Assert.AreEqual(-5, graph.GetVertexProp(v1));

            graph.Clear();
            Assert.Throws <GeomException>(() => graph.GetVertexProp(v1));

            graph.AddVertex(v0);
            graph.AddVertex(v1);
            var e = new Edge(v0, v1);

            graph.AddEdge(e);
            Assert.AreEqual(default(int), graph.GetEdgeProp(e));
            graph.SetEdgeProp(e, int.MaxValue);
            Assert.AreEqual(int.MaxValue, graph.GetEdgeProp(e));

            graph.Clear();

            Assert.Throws <GeomException>(() => graph.GetEdgeProp(e));
        }
Esempio n. 2
0
        public void testClear()
        {
            AdjacencyListGraph <string, string> g = graph(n1, n2, n3, n4);

            g.AddEdge(e1); g.AddEdge(e2); g.AddEdge(e3); g.AddEdge(e4);

            g.Clear();
            Assert.IsTrue(g.IsEmpty());
        }