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); }
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); }
public void RemoveEdge(GraphEdge edge) { InEdges.Remove(edge); }
public void AddEdge(GraphEdge edge) { InEdges.Add(edge); }