A local algorithm for detecting community structures in dynamic networks