exhaustive search algorithm

Please review my pseudo code using exhaustive search algorithm to find all subsets of N vertices that are not connected. Thanks!

The undirected graph is in the adjacent matrix form.

Thank you!

N_NotConnectedVertices (Graph G){

Do{

S = New N-subset from G //generate a subset

bool notConnected = true; //assume S is not connected

for each vertices1 in S

for each vertices2 in S

if vertices1 is adjacent to vertices2
notConnected = false;

if S is notConnected, then return true

}while(G contains more N-subsets)

return false; //there are no N-subsets
}
Last edited on
Topic archived. No new replies allowed.