added exception for len(G.nodes()) < 2. The algorithm can only detect communities when there is more than 1 node.
added exception for directed graphs
removed some debugging code