コード例 #1
0
            /// <summary>
            /// Drains the todo list
            /// </summary>
            private void IterativeDFS()
            {
                while (todo.Count > 0)
                {
                    SearchFrame sf = todo.Peek();
                    Contract.Assume(sf.Edges != null);

                    if (sf.Edges.MoveNext())
                    {
                        var edgeTarget = sf.Edges.Current;

                        Contract.Assume(sf.Info != null);

                        this.VisitEdgeNonRecursive(sf.Info, sf.Node, edgeTarget.One, edgeTarget.Two);
                        continue; // make sure to visit new edges first.
                    }
                    // done with this frame.
                    if (nodeFinishVisitor != null)
                    {
                        nodeFinishVisitor(sf.Node);
                    }

                    Contract.Assume(sf.Info != null);
                    sf.Info.FinishTime = ++time;
                    todo.Pop();
                }
            }
コード例 #2
0
 public MainPage()
 {
     InitializeComponent();
     SearchFrame.TranslateTo(transition, 0, 1);
     SearchFrame.FadeTo(0, 1);
     SearchFrame.IsVisible = false;
 }
コード例 #3
0
        private async void SearchBar_Unfocused(object sender, FocusEventArgs e)
        {
            SearchFrame.TranslateTo(transition, 0, 200);
            TitleControls.FadeTo(1, 200);
            await SearchFrame.FadeTo(0, 200);

            SearchFrame.IsVisible = false;
        }
コード例 #4
0
        public void Visit(TVertex root, int depth)
        {
            if ((object)root == null)
            {
                throw new ArgumentNullException("root");
            }

            Stack <SearchFrame> todo = new Stack <SearchFrame>();

            this.VertexColors[root] = GraphColor.Gray;
            OnDiscoverVertex(root);

            todo.Push(new SearchFrame(root, this.VisitedGraph.OutEdges(root).GetEnumerator()));
            while (todo.Count > 0)
            {
                if (this.IsAborting)
                {
                    return;
                }

                SearchFrame frame = todo.Pop();

                TVertex             u     = frame.Vertex;
                IEnumerator <TEdge> edges = frame.Edges;
                while (edges.MoveNext())
                {
                    TEdge e = edges.Current;
                    if (this.IsAborting)
                    {
                        return;
                    }
                    this.OnExamineEdge(e);
                    TVertex    v = e.Target;
                    GraphColor c = this.VertexColors[v];
                    switch (c)
                    {
                    case GraphColor.White:
                        OnTreeEdge(e);
                        todo.Push(new SearchFrame(u, edges));
                        u     = v;
                        edges = this.VisitedGraph.OutEdges(u).GetEnumerator();
                        this.VertexColors[u] = GraphColor.Gray;
                        this.OnDiscoverVertex(u);
                        break;

                    case GraphColor.Gray:
                        OnBackEdge(e); break;

                    case GraphColor.Black:
                        OnForwardOrCrossEdge(e); break;
                    }
                }

                this.VertexColors[u] = GraphColor.Black;
                this.OnFinishVertex(u);
            }
        }
コード例 #5
0
        private async void Search_Tapped(object sender, EventArgs e)
        {
            SearchFrame.IsVisible = true;
            TitleControls.FadeTo(0, 200);
            await SearchIndicator.ScaleTo(1.4, 85);

            SearchIndicator.ScaleTo(1, 85);
            SearchFrame.FadeTo(1, 170);
            await SearchFrame.TranslateTo(0, 0, 200);

            SearchBar.Focus();
        }
コード例 #6
0
ファイル: DepthFirst.cs プロジェクト: raj581/Marvin
 private void IterativeDFS()
 {
     while (this.todo.Count > 0)
     {
         SearchFrame frame = this.todo.Peek();
         if (frame.Edges.MoveNext())
         {
             Pair <Edge, Node> current = frame.Edges.Current;
             VisitEdgeNonRecursive(frame.Info, frame.Node, current.Key, current.Value);
         }
         else
         {
             if (this.node_finish_visitor != null)
             {
                 this.node_finish_visitor(frame.Node);
             }
             frame.Info.FinishTime = ++this.time;
             this.todo.Pop();
         }
     }
 }