Ejemplo n.º 1
0
        public IScannedGraphResult <TVertex, TEdge> TraverseGraph(
            IUndirectedGraph <TVertex, TEdge> undirectedGraph,
            TVertex sourceVertex)
        {
            var markedVertices     = new HashSet <TVertex>();
            var vertexToParentEdge = new Dictionary <TVertex, TEdge>();

            var toto = undirectedGraph.GetAdjacentsToVertex(sourceVertex);

            foreach (var edge in toto)
            {
            }

            return(this.scannerResultfactory.CreateResult(sourceVertex, markedVertices, vertexToParentEdge));
        }
Ejemplo n.º 2
0
        public IScannedGraphResult <TVertex, TEdge> TraverseGraph(
            IUndirectedGraph <TVertex, TEdge> undirectedGraph,
            TVertex sourceVertex)
        {
            var markedVertices = new HashSet <TVertex>();

            // var vertexToParentVertex = new Dictionary<TVertex, TVertex>();
            var vertexToParentEdge = new Dictionary <TVertex, TEdge>();

            var queue = new Queue <TVertex>();

            queue.Enqueue(sourceVertex);

            markedVertices.Add(sourceVertex);

            while (queue.Any())
            {
                var currentVertex = queue.Dequeue();
                foreach (var edge in undirectedGraph.GetAdjacentsToVertex(currentVertex))
                {
                    var vertex = edge.GetOtherVertex(currentVertex);

                    if (!markedVertices.Add(vertex))
                    {
                        continue;
                    }

                    // vertexToParentVertex[vertex] = currentVertex;
                    vertexToParentEdge[vertex] = edge;

                    queue.Enqueue(vertex);
                }
            }

            return(this.scannerResultfactory.CreateResult(sourceVertex, markedVertices, vertexToParentEdge));
        }