A novel algorithm named randomized binary gravitational search (RBGS) algorithm is proposed for the set covering problem (SCP). It differs from previous SCP approaches because it does not work directly on the SCP matrix. In the proposed algorithm, the solution of SCP is viewed as multi-dimension position of objects in the binary search space. All objects in the space attract each other by the gravity force, and this force causes a global movement of all objects towards the objects with heavier masses which correspond to good solutions. Computation results show that the proposed algorithm is very competitive. In addition, the proposed algorithm is extended for SCP to solve the fault diagnosis problem in graph-based systems.