Tag: 顶点

使用List和Stack实现深度优先搜索到C#

我想创建一个深度优先搜索,我已经有点成功了。 这是我到目前为止的代码(除了我的构造函数,请注意Vertex和Edge类只包含属性,这里没有重要的内容): private Stack workerStack = new Stack(); private List vertices = new List(); private List edges = new List(); private int numberOfVertices; private int numberOfClosedVertices; private int visitNumber = 1; private void StartSearch() { // Make sure to visit all vertices while (numberOfClosedVertices 0) { // Get top element in stack and mark it […]