Ejemplo n.º 1
0
        public bool HideVertex(TVertex v, string tag)
        {
            HiddenCollection h = GetHiddenCollection(tag);
            var eeh            = new EdgeAction <TVertex, TEdge>(e => h.hiddenEdges.Add(e));
            var veh            = new VertexAction <TVertex>(vertex => h.hiddenVertices.Add(vertex));

            EdgeHidden   += eeh;
            VertexHidden += veh;
            bool ret = HideVertex(v);

            EdgeHidden   -= eeh;
            VertexHidden -= veh;
            return(ret);
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public bool HideVertex(TVertex vertex, string tag)
        {
            HiddenCollection collection = GetHiddenCollection(tag);
            var hideEdgeHandler         = new EdgeAction <TVertex, TEdge>(e => collection.HiddenEdges.Add(e));
            var hideVertexHandler       = new VertexAction <TVertex>(v => collection.HiddenVertices.Add(v));

            EdgeHidden   += hideEdgeHandler;
            VertexHidden += hideVertexHandler;

            bool hidden = HideVertex(vertex);

            EdgeHidden   -= hideEdgeHandler;
            VertexHidden -= hideVertexHandler;

            return(hidden);
        }
Ejemplo n.º 3
0
        public static VertexPredecessorRecorderObserver <TVertex, TEdge> GetPredecessors <TVertex, TEdge> (this IVertexListGraph <TVertex, TEdge> graph, TVertex obj, VertexAction <TVertex> onVertex) where TEdge : IEdge <TVertex>
        {
            var bfsa = new BreadthFirstSearchAlgorithm <TVertex, TEdge> (graph);

            bfsa.ExamineVertex += (vertex) => {
                onVertex?.Invoke(vertex);
            };

            var vertexPredecessorRecorderObserver = new VertexPredecessorRecorderObserver <TVertex, TEdge> ();

            using (vertexPredecessorRecorderObserver.Attach(bfsa)) {
                bfsa.Compute(obj);
            }

            return(vertexPredecessorRecorderObserver);
        }