give number n b you need find adjacency matrix undirected graph number component equal number component complement b the matrix symmetric digit main diagonal zeroesin undirected graph loop edge vertex allow it edge pair verticesthe adjacency matrix undirected graph square matrix size n consist 0 1 n number vertex graph ith row ith column correspond ith vertex graph the cell ij adjacency matrix contain 1 ith jth vertices graph connect edgeA connect component set vertex x vertex set exist path graph connect pair vertex add vertex x violate ruleThe complement inverse graph g graph H vertice distinct vertex h adjacent adjacent g