View source: R/cluster_milano.R
| cluster_milano | R Documentation |
Calculates the partition with maximum global null-adjuted persistence.
cluster_milano(vertex, edge_list, seed = NULL)
vertex |
the vertices of the graph, whose label are integers and they must be consistent with the edge sets. |
edge_list |
the graph edge list in the form of an integer matrix with two columns. |
seed |
As some steps of the algorithm are random, users may experiments with different seeds of random numbers. |
A list containing:
The optimal vertex partition.
The null-adjusted persistence of the partition.
The used seed to generate random numbers.
library(persistence)
library(igraph)
edg = c(1, 2, 1, 3, 1, 4, 2, 3, 3, 4, 4, 5, 5, 6, 5, 7, 5, 8, 5, 9, 6, 7, 6, 8, 7, 9, 8, 9)
print(length(edg) / 2.0)
vertex = unique(edg)
edg = t(matrix(as.integer(edg), nrow = 2 ))
rete <- graph_from_edgelist(edg, directed = FALSE)
plot(rete)
seed <- sample(1:as.integer(.Machine$integer.max),1, replace= FALSE)
r = cluster_milano(vertex, edg, seed=seed)
print(paste("The optimal null-adjusted persistence is: ", r$measure))
print(paste("The optimal persistence probability is: ", r$measure + 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.