public void TestEdgeCount() { 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); 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); Assert.AreEqual(2, graph.EdgeCount); graph.AddEdge(0, 11001, new uint[] { 20 }, null); Assert.AreEqual(3, graph.EdgeCount); Assert.AreEqual(2, graph.RemoveEdges(0, 11001)); Assert.AreEqual(1, graph.EdgeCount); Assert.AreEqual(1, graph.RemoveEdges(0, 1)); Assert.AreEqual(0, graph.EdgeCount); }
public void TestRemoveEdges() { var graph = new GeometricGraph(1, 100); // add and remove edge. graph.AddVertex(0, 0, 0); graph.AddVertex(1, 0, 0); graph.AddEdge(0, 1, new uint[] { 10 }, null); Assert.AreEqual(1, graph.RemoveEdges(0)); Assert.AreEqual(0, graph.RemoveEdges(1)); // verify all edges. var edges = graph.GetEdgeEnumerator(0); Assert.AreEqual(0, edges.Count()); edges = graph.GetEdgeEnumerator(1); Assert.AreEqual(0, edges.Count()); graph = new GeometricGraph(1, 100); // add and remove edges. graph.AddVertex(0, 0, 0); graph.AddVertex(1, 0, 0); graph.AddVertex(2, 0, 0); graph.AddEdge(0, 1, new uint[] { 10 }, null); graph.AddEdge(0, 2, new uint[] { 10 }, null); Assert.AreEqual(2, graph.RemoveEdges(0)); // verify all edges. edges = graph.GetEdgeEnumerator(0); Assert.AreEqual(0, edges.Count()); edges = graph.GetEdgeEnumerator(1); Assert.AreEqual(0, edges.Count()); edges = graph.GetEdgeEnumerator(2); Assert.AreEqual(0, edges.Count()); graph = new GeometricGraph(1, 100); // add and remove edges. graph.AddVertex(0, 0, 0); graph.AddVertex(1, 0, 0); graph.AddVertex(2, 0, 0); graph.AddEdge(0, 1, new uint[] { 10 }, null); graph.AddEdge(0, 2, new uint[] { 20 }, null); graph.AddEdge(1, 2, new uint[] { 30 }, null); Assert.AreEqual(2, graph.RemoveEdges(0)); // verify all edges. edges = graph.GetEdgeEnumerator(0); Assert.AreEqual(0, edges.Count()); edges = graph.GetEdgeEnumerator(1); Assert.AreEqual(1, edges.Count()); edges = graph.GetEdgeEnumerator(2); Assert.AreEqual(1, edges.Count()); }
public void TestRemoveEdge() { var graph = new GeometricGraph(1, 100); // add and remove edge. graph.AddVertex(0, 0, 0); graph.AddVertex(1, 0, 0); graph.AddEdge(0, 1, new uint[] { 1 }, null); Assert.IsTrue(graph.RemoveEdges(0, 1) != 0); graph = new GeometricGraph(1, 100); // add and remove edge. graph.AddVertex(0, 0, 0); graph.AddVertex(1, 0, 0); var edge = graph.AddEdge(0, 1, new uint[] { 10 }, null); Assert.IsTrue(graph.RemoveEdge(edge)); }
/// <summary> /// Removes all edges from/to the given vertex. /// </summary> /// <returns></returns> public int RemoveEdges(uint vertex) { return(_graph.RemoveEdges(vertex)); }