void UGraph::BST(int source)
{
    bool *visited;
    visited = new bool[Nodes.size()];
    for(int i = 0 ; i < Nodes.size() ;i++) visited[i] = false;

    if(!nodeExist(source)) std::cout<<"Node does not exist"<< std::endl;
    else
    {
        std::queue<int> nodeq;
        nodeq.push(source);
        while(!nodeq.empty())
        {
            int node_i = nodeq.front();
            if(!visited[node_i])
            {
                visited[node_i] = true;
                std::vector<int> children = Nodes[node_i].edges();
                for(int j = 0 ; j < children.size() ; j++) nodeq.push(children[j]);
            }
            nodeq.pop();
        }



    }

}
示例#2
0
Cycle * IGraph::cycleFinding(int first, int last, int user)
{
	if (size() == 0)
		return 0;
	
	if (!nodeExist(first, last, user))
		return 0;

	return doCycleFinding(first, last, user);
}
示例#3
0
bool IGraph::updateNode(int old_first, int old_last, int old_user, float old_coef, int new_first, int new_last, int new_user, float new_coef)
{
	if (size() == 0)
		return false;
		
	if (!nodeExist(old_first, old_last, old_user))
		return false;

	return doUpdateNode(old_first, old_last, old_user, old_coef, new_first, new_last, new_user, new_coef);
}
示例#4
0
bool IGraph::deleteNode(int first, int last, int user)
{
	if (size() <= 0)
		return false;
	
	if (!nodeExist(first, last, user))
		return false;

	return doDeleteNode(first, last, user);
}
示例#5
0
bool IGraph::readNode(int first, int last, int user, Node *node)
{
	if (size() == 0)
		return false;

	if (!nodeExist(first, last, user))
		return false;

	return doReadNode(first, last, user, node);
}