# Transforming dissimilarity matrix for use as weights in network

I'm trying to identify communities or clusters in a network by optimizing the modularity function. The network is a fully connected network, with undirected edges that have weights based on a pairwise matrix. The problem is that the matrix is a distance matrix where 0 indicates two points are identical and 1 indicates they are completely different, which doesn't make sense for weights. There are a few different simple ways I can come up with to fix this:

• Divide the matrix into 1 to get the reciprocal/inverse
• Subtract the matrix from 1 (is there a technical term for this?)

These effectively turn the distance matrix into a similarity matrix. I have the code implemented, and they both give different results that make sense. The first gives me two different clusters, while the second gives me only one.

On top of that, in some cases my distance values lie within a small range of the possible values, which is why I think the second approach above only gives me one cluster.

The question is, what is appropriate for converting a distance or dissimilarity matrix to a similarity matrix for use as weights in a network that is going to be used for community detection?