Пример #1
0
void depthFirstSearchNonRec(Graph *graph, int visited[], int vertex) {
//mark it as visited
    int i, currVertex;
    Stack *stack;
    visited[vertex] = 1;

    stack = initStack(graph->V);
    push(stack, vertex);

    //push vertex on stack
    while(!isEmpty(stack)) { //stack not empty
        //pop node from top of stack
        currVertex = pop(stack);

        visited[currVertex] = 1;
        printf(" %d,", currVertex);

        //visit all its neighbours
        for(i = graph->V - 1; i >=0 ; i--) {
            //if neighbour is not visited then
            if((graph->edgeMat[currVertex][i] == 1) && (visited[i] == 0)) {
                 //push it on top of the stack
                 push(stack, i);
            }
            //do for all vertices
        }
    }
    releaseStack(stack);
}
Пример #2
0
void 
Babuino::reset()
{
	//_stack.reset();
	if (_stack)
		releaseStack(_stack);
	_stack = allocateStack(STACK_SIZE);

	_selectedMotors = Motors::MOTOR_NONE;
	_timerCount     = 0;
    _defaultStream = &Serial;

	_regs.pc               = 0;
	_regs.opCode           = OP_INVALID;
	_regs.withCode         = OP_WITHINT16; // Gogo board default
	getStackState(_stack, &_regs.localFrame);
	_regs.repcountLocation = ~0;
	_regs.blockDepthMask   = 0;
	_regs.blocksExecuted   = 0;

	_states.setRunRequest(STOPPED);
	_states.setMachineState(READY);
	_states.setCommState(COMM_IDLE);
}