Commit 087efa88 by xiaotong

TarjanVisit code

parent 59a7030a
......@@ -23,7 +23,7 @@
namespace nts{
unsigned unsigned int netIDGlobal = 0;
unsigned int netIDGlobal = 0;
MUTEX_HANDLE netMutex;
/* generate a network id */
......@@ -109,7 +109,12 @@ depth-first search (Tarjan's algorithm)
*/
void XNet::Traverse(XList &roots)
{
id = MakeNetID();
nodes.Clear();
for (int i = 0; i < roots.count; i++)
TarjanVisit((XTensor*)roots.Get(i), nodes, id);
}
/*
......@@ -126,7 +131,7 @@ void XNet::TarjanVisit(XTensor * node, XList &orders, const unsigned int code)
if(node->visitMark == code + 1){
ShowNTErrors("There is a circle in the network\n");
}
else if(node->visitMark <= code || node->visitMark > code + 2){
else if(node->visitMark <= code || node->visitMark >= code + 2){
node->visitMark = code + 1;
XLink &income = node->income;
for(int i = 0; i < income.tailNum; i++){
......
......@@ -32,6 +32,9 @@ namespace nts{
/* management of tensor net (or graph) */
struct XNet
{
/* id of the network */
unsigned int id;
/* tensor nodes of the network (in order) */
XList nodes;
......
......@@ -140,7 +140,7 @@ public:
bool isTmp;
/* mark for traversing the gragh */
int visitMark;
unsigned int visitMark;
/*
the link used to form networks. Note that when we compute on tensors, we actually create a
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论