Esempio n. 1
0
        public static void GraphHasCorrectNumberOfEdges <K, T>(int expectedEdges, List <GraphVertex <K, T> > graph)
            where K : IUnfoldableEdge
            where T : IUnfoldablePlanarFace <K>
        {
            var alledges = GraphUtilities.GetAllGraphEdges(graph);

            Assert.AreEqual(expectedEdges, alledges.Count);
            Console.WriteLine("correct number of edges");
        }
        // Method to remove this graphvertex from graph and to remove all edges which point to it
        // from other nodes in the graphT
        public void RemoveFromGraph(List <GraphVertex <K, T> > graph)
        {
            //collect all edges
            var allGraphEdges = GraphUtilities.GetAllGraphEdges(graph);
            var edgesToRemove = new List <GraphEdge <K, T> >();

            // mark all edges we need to remove
            foreach (var edge in allGraphEdges)
            {
                if (edge.Head == this)
                {
                    edgesToRemove.Add(edge);
                }
            }
            // iterate the graph again, if during traversal we see
            // a marked edge, remove it

            foreach (var vertex in graph)
            {
                vertex.GraphEdges.ExceptWith(edgesToRemove);
            }
            //finally remove the node
            graph.Remove(this);
        }