Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/150.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 哈密顿路径+;拓扑排序_C++_Algorithm_Sorting_Topological Sort_Hamiltonian Cycle - Fatal编程技术网

C++ 哈密顿路径+;拓扑排序

C++ 哈密顿路径+;拓扑排序,c++,algorithm,sorting,topological-sort,hamiltonian-cycle,C++,Algorithm,Sorting,Topological Sort,Hamiltonian Cycle,我知道,如果拓扑排序的属性是排序顺序中的所有连续顶点对都由边连接,那么拓扑排序顺序是唯一的。我的问题是,我不能在C++中实现它,尤其是在比较中。在最后一个例子中,我想看看vetorTop邻接列表中是否有拓扑排序中它旁边的数字。但似乎大学学位并没有给我这个结果。下面是我的代码: int u; for (int i=1; i<(int)vetorTop.size(); i++){ //topological sorted u = vetorTop[i];

我知道,如果拓扑排序的属性是排序顺序中的所有连续顶点对都由边连接,那么拓扑排序顺序是唯一的。我的问题是,我不能在C++中实现它,尤其是在比较中。在最后一个例子中,我想看看vetorTop邻接列表中是否有拓扑排序中它旁边的数字。但似乎大学学位并没有给我这个结果。下面是我的代码:

    int u;
    for (int i=1; i<(int)vetorTop.size(); i++){ //topological sorted
        u = vetorTop[i];
        list<int>::iterator itr;
        for (itr = adj[u].begin(); itr != adj[u].end(); itr++){
            if (vetorTop[i+1] == in_degree[*itr]++){
                cout << "NOT UNIQUE\n";
                return;
            }
        }
    }
intu;

对于(int i=1;我来谈谈堆栈溢出。我建议您看看。您没有给我们足够的信息来回答这个问题,甚至没有理解它。我希望它更清楚,您可以帮助我@BetaWhere是在定义和填充的程度上的吗?这里有一些可能是错误的,但我不能确定,因为我不知道这些是什么变量既不包含,也不应该包含。元素在
中的值在_degree
中是什么意思,为什么要增加它?投票关闭。