I am trying to use some R packages such as "stats" and "fpc" to calculate cophenetic correlation coefficient (like the method here) and some internal validations of my hierarchical clustering result(like the method using cluster.stats() mentioned here)
But as my weighted graph is disconnected (has several separate components of nodes), some nodes are unreachable by the others and their distances are infinite (Inf). The distance matrix looks pretty much like this.
The R packages I found so far seems can't deal with Inf in the distance matrix. But then if I remove Inf, the length of the distance matrix and my clustering result won't match, and I can't replace Inf with zero in this case either.
I found out that when R package"igraph" calculate closeness (sum of distances) of a disconnected graph, it would replace Inf with the number of vertices in the network. I wonder can I apply this method to my distance matrix? (ex: My graph has 95 nodes so I replace all the Inf with 95 in the matrix.)
Or is there any other way? Maybe I should focus on each component one time instead of the whole graph?(But since one of my graphs is very disconnected, I'm not sure this is a good idea).