We consider the problem of discovering and representing the topology of a modular self-reconfigurable robot (MSR) in which modules do not have a priori information about the locations of and connections with other modules participating in the configuration. To represent the topology of the configuration, we propose to combine two main features; the geometric shape of the module, and the graph that represents connectivity among modules. In order to obtain the graph, it is necessary to discover the modules that are in the current configuration. This process is done by sharing IDs, creating a local configuration structure (LCS) or list of local neighbors, propagating LCSs among the modules, and building up an adjacency matrix based on the LCSs. To increase the autonomy and robustness of the system, we consider a distributed architecture in which each module is able to discover the configuration by itself. This work is based on the combination of Infra-Red and XBee communication protocols, and the limited computational resources available in a module. For testing, demonstration, and validation purposes, we have implemented the approach in a robotic platform called ModRED (Modular Robot for Exploration and Discovery).