#include <stdio.h>
#include "misc.h"
#include "graph.h"

int main(int argc, char *argv[])
{
    int BFSsize, i, j;
    GRAPH *G = GraphReadConnections(stdin);
    GRAPH *Gbar = GraphComplement(NULL, G);
    GRAPH *GG = GraphComplement(NULL, Gbar);
    printf("Checking sanity of Complement(Complement(G))...");
    assert(GG->n == G->n);
    for(i=0; i<G->n; i++)
    {
	assert(SetEq(GG->A[i], G->A[i]));
	assert(GG->degree[i] == G->degree[i]);
	for(j=0;j<G->n; j++)
	    assert(GG->neighbors[i][j] == GG->neighbors[i][j]);
    }
    puts("passed!");
    printf("Now check BFS:\n");

    while(1)
    {
	int root, distance, nodeArray[GG->n], distArray[GG->n];
	GraphFree(GG);
	GG = GraphCopy(NULL, G);
	printf("enter BSF start node, distance: "); fflush(stdout);
	if(scanf("%d%d", &root, &distance) != 2)
	    break;
	BFSsize = GraphBFS(GG, root, distance, nodeArray, distArray);
	for(i=0; i<BFSsize; i++)
	    printf("%d(%d) ", nodeArray[i], distArray[nodeArray[i]]);
	printf("\n");
    }

    return 0;
}
