10
$\begingroup$

I have a graph instance with weighted directed edges which values can be in range [-1,1]. I need to do clustering on this graph, in order to find out groups in which vertices are more correlated.

I searched for several clustering or community detection graph based algorithms, but most of them don't work because the negative weights. Up to now I have applied spinglass (it is so called in igraph library, it is an algorithm based on Potts model) algorithm which seems to work with both positive and negative weights.

Are there any other algorithms for doing clustering or community detection on graphs which have negative and positive edge weights?

Update: the edge weights represent correlations, 1 means that two vertices are strongly correlated, -1 that are inversely correlated and 0 means that are indipendent.

$\endgroup$
8
  • $\begingroup$ What do the weights represent? $\endgroup$
    – eliasah
    Oct 18, 2015 at 16:43
  • $\begingroup$ @eliasah I did an update in order to explain that $\endgroup$
    – Ewybe
    Oct 18, 2015 at 16:54
  • $\begingroup$ Did you try using another scale? That might be a good solution using a regular clustering method based on betweenness centrality algorithm per example. $\endgroup$
    – eliasah
    Oct 18, 2015 at 17:05
  • $\begingroup$ @eliasah Scaling these data imay be not so easy because I am interested in preserve the meaning of the correlation $\endgroup$
    – Ewybe
    Oct 18, 2015 at 17:39
  • 2
    $\begingroup$ For the clustering, is the sign of the correlation really needed? Inverse correlation is a pretty strong relationship, too. See my answer below. $\endgroup$ Oct 18, 2015 at 22:24

5 Answers 5

3
$\begingroup$

Have you tried mapping the values to [0;2]?

Then many algorithms may work.

Consider e.g. Dijkstra: it requires non-negative edge weights, but if you know the minimum a of the edges, you can run it on x-a and get the shortest cycle-free path.

Update: for correlation values, you may either be interested in the absolute values abs(x) (which is the strength of the correlation!) or you may want to break the graph into two temporarily: first cluster on the positive correlations only, then on the negative correlations only if the sign is that important for clustering & the previous approaches don't work.

$\endgroup$
7
  • $\begingroup$ That's somehow what I have suggested, he said that he will "lose the meaning of the correlation". What do you think about that? $\endgroup$
    – eliasah
    Oct 18, 2015 at 21:42
  • $\begingroup$ With his updated description, abs(x) may work even better. $\endgroup$ Oct 18, 2015 at 22:23
  • $\begingroup$ Nevertheless I believe [0,2] is more representative. Weighted graphs usually have very big importance on these matters to compute centrality, distance, diameter, etc. $\endgroup$
    – eliasah
    Oct 18, 2015 at 22:26
  • 1
    $\begingroup$ That does not mean you cannot discriminate afterwards. Have you tried it, the results may still be useful? $\endgroup$ Oct 19, 2015 at 8:14
  • 1
    $\begingroup$ Then try the other approach - finding positive and negative cluster separately. $\endgroup$ Oct 19, 2015 at 20:34
2
$\begingroup$

Yes, there is an algorithm called 'Affinity Propagation' that works with negative weights; I believe this is implemented in sklearn (see the documentation here). A reference for what is going on behind the scenes can be found here.

Hope that's what you're looking for!

$\endgroup$
2
  • $\begingroup$ I did not know this algorithm, it seems to be a good solution. I certainly will try it. Thank you. $\endgroup$
    – Ewybe
    Oct 18, 2015 at 17:40
  • $\begingroup$ As far as I know Affinity Propagation clustering will not be able to simultaneously consider positive and negative correlations whilst also separating them. For that matter, I think the task is contradictory. $\endgroup$
    – micans
    Oct 19, 2015 at 15:47
1
$\begingroup$

It seems to me the problem you describe is known as the Correlation Clustering Problem. This information should help you find some implementations, such as:

Note some community detection algorithms have also been modified in order to process signed networks, e.g. Amelio'13, Sharma'12, Anchuri'12, etc. However, I couldn't find any publicly available implementation.

$\endgroup$
1
$\begingroup$

Take a look at this code, it is quite scalable, works with positive and negative edges, and solves Correlation Clustering (CC) as a special case (r = 0). However, for the case of CC (maximizing positive links and minimizing negative links inside clusters), I would suggest other methods that are specialized in solving this objective.

To illustrate, Correlation Clustering (unlike what Community Detection literature pursues) does not take the positive density of clusters into account, so when a network has no or few negative ties (most real-world cases), all the network is put into one big cluster.

$\endgroup$
1
$\begingroup$

We sometimes call these graphs 'signed graphs' or 'signed networks' as links can be positive and negative (or even weighted, as in your case), where a negative link means the nodes are anti-correlated and thus should be repulsed iso attracted. In a social network setting for example a negative link could model a situation of two users that are enemies.

Take a look at Traag's Leidenalg, who integrated repulsion between negative ties in various graph clustering (community detection) algorithms, all code available through the python leidenalg module, easy to use.

https://leidenalg.readthedocs.io/en/stable/multiplex.html#negative-links https://www.nature.com/articles/s41598-019-41695-z

some other useful refs (using the algorithm)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.