int main(int argc, char const *argv[])
{
	int set[SIZE]={7,4,6,13,20,8};
	int answer[SIZE];
	printf("use DFS:\n");
	BFS_search(set,answer,0);
	printf("use Branch and Bound:\n");
	branchbound(set,answer,0);
	return 0;
}
void BFS_search(int *set,int *answer,int step){
	int summary=sum(set,answer,step);
	if(step==SIZE ){
		if(summary==K)
			displayoutcome(set,answer,step);
		return ;
	}
	int sel;
	for(sel=0;sel<2;sel++){
		answer[step]=sel;
		BFS_search(set,answer,step+1);
	}
}
inline set<Node*> NFA::find_valid_states(const EpsilonNFA & enfa)
{
    set<Node*> validStates;
    auto apply = [&validStates](Node* node) {
        for (const auto& edge : node->edges)
        {
            if (edge.accept != '\0')
            {
                validStates.insert(edge.next);
            }
        }
    };
    BFS_search(enfa, apply);
    validStates.insert(enfa.start_state());
    return validStates;
}
Exemple #4
0
void BFS(pnodo *L,		/* lista delle adiacenze		*/
		 pnodo *P_in,	/* pila ordine visita			*/
		 int n,			/* numero di vertici			*/
		 int *c,		/* colore vertici				*/
		 int *p,		/* precedente di un vertice		*/
		 int *d			/* depth del vertice nella BFS	*/
		 )
{
	int v, i;
	for(i=0;i<n;i++){
		c[i] = 0;
		p[i] = d[i] = -1;
	}
	while(*P_in){
		v = pop(P_in);
		if( c[v] == 0){
			printf("%d (d = 0, p = -1)",v);
			BFS_search(v, L, c, p, d);
			printf("\n");
		}
	}
}