I'm working on a TreeDecomposition where each node in a tree can have more than one vertices from the graph.
Now, i'm trying to find the first node which contains a vertex u from the root of tree.
int Tree::traversing(Node* node, int u){
//search in current node
int j = node->point_in_bag(u); //this function returns position of vertex u in node if not available -1
if(j != -1){
return node->index;
}
else{
// traverse in its children
for(int k=0; k<node->children.size(); k++){ // children has the node's childs in it
Node* nod = node->children[k];
cout << "nod index is " << nod->index << endl;
traversing(nod,u); // if vertex isn't found in node, traverse again in its children
}
}
}
i have tried like above, but its not returning the exact node index. where am i doing wrong.