public void TestVertexCountAndTrim() { var graph = new GeometricGraph(1, 100); // add edge. graph.AddVertex(0, 0, 0); graph.AddVertex(1, 0, 0); graph.AddEdge(0, 1, new uint[] { 10 }, null); // trim. graph.Trim(); Assert.AreEqual(2, graph.VertexCount); Assert.AreEqual(1, graph.EdgeCount); graph = new GeometricGraph(1, 100); // add edge. graph.AddVertex(0, 0, 0); graph.AddVertex(1, 0, 0); graph.AddVertex(11001, 0, 0); graph.AddEdge(0, 1, new uint[] { 10 }, null); graph.AddEdge(0, 11001, new uint[] { 10 }, null); // trim. graph.Trim(); Assert.AreEqual(11002, graph.VertexCount); Assert.AreEqual(2, graph.EdgeCount); graph = new GeometricGraph(1, 100); // trim. graph.Trim(); // keep minimum one vertex. Assert.AreEqual(0, graph.VertexCount); }
/// <summary> /// Resizes the internal data structures to their smallest size possible. /// </summary> public void Trim() { _graph.Trim(); _edgeData.Resize(_graph.EdgeCount); }