path.kruskal_covid: Basic description

Description Usage Arguments Value See Also Examples

Description

Calculates the shortest Hamiltonian path based on the sorted edge weights and the nodes

Usage

1
path.kruskal_covid(nodes,edge_cost)

Arguments

nodes

sequence of nodes 1,...,n from the graph which is based on the high-dimensional data that is provided by the reader

edge_cost

sorted edge weights

Value

the shortest Hamiltonian path

See Also

Hpath_covid

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# path.kruskal is used in the Hpath function as follows:
Hpath_covid=function(n1,n2,mat){
n0=n2-n1+1
edge.cost=matrix(NA,nrow=n0*(n0-1)/2,ncol=3)

temp=1;

for(i in n1:(n2-1))
for(j in (i+1):(n2))
{
edge.cost[temp,3]=mat[i,j];edge.cost[temp,1]=i-n1+1;edge.cost[temp,2]=j-n1+1;temp=temp+1;}

edge.cost=edge.cost[sort.list(edge.cost[,3]), ]

#based on path

opt.path=path.kruskal_covid(c(1:n0),edge.cost)

return(opt.path$edge.cost[,1:2])
}

Meiqian-Chen/GraphCpClust documentation built on April 27, 2021, 10:40 a.m.