private bool DarkSearch()
        {
            if (SrcID != -1 && DstID != -1)
            {
                Stack <GraphEdge> stacks = new Stack <GraphEdge>();

                //SortedSet<float>

                DummyEdge.Src  = SrcID;
                DummyEdge.Dst  = SrcID;
                DummyEdge.Cost = 0;

                stacks.Push(DummyEdge);

                while (stacks.Count != 0)
                {
                    GraphEdge next = stacks.Pop();

                    Route[next.Dst] = next.Src;

                    if (next != DummyEdge)
                    {
                        SpanningTree.Add(next);
                    }

                    Visited[next.Dst] = GraphSearchState.Visited;

                    if (next.Dst == DstID)
                    {
                        return(true);
                    }

                    foreach (var edge in Graph.GetEdgesFrom(next.Dst))
                    {
                        if (Visited[edge.Dst] == GraphSearchState.UnVisited)
                        {
                            stacks.Push(edge);
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        private bool DarkSearch()
        {
            if (SrcID != -1 && DstID != -1)
            {
                Queue <GraphEdge> queues = new Queue <GraphEdge>();

                DummyEdge.Src  = SrcID;
                DummyEdge.Dst  = SrcID;
                DummyEdge.Cost = 0;

                queues.Enqueue(DummyEdge);

                while (queues.Count != 0)
                {
                    GraphEdge next = queues.Dequeue();

                    Route[next.Dst] = next.Src;

                    if (next != DummyEdge)
                    {
                        SpanningTree.Add(next);
                    }

                    Visited[next.Dst] = GraphSearchState.Visited;

                    if (next.Dst == DstID)
                    {
                        return(true);
                    }

                    foreach (var edge in Graph.GetEdgesFrom(next.Dst))
                    {
                        if (Visited[edge.Dst] == GraphSearchState.UnVisited)
                        {
                            queues.Enqueue(edge);
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 3
0
 public void RemoveEdge(GraphEdge edge)
 {
     InEdges.Remove(edge);
 }
Exemplo n.º 4
0
 public void AddEdge(GraphEdge edge)
 {
     InEdges.Add(edge);
 }