-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclusterQtxt.jl
41 lines (31 loc) · 959 Bytes
/
clusterQtxt.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
read a Q matrix from a .txt in ijv format
and use PCCA to cluster it
requires the PCCA pkg to be installed:
`Pkg.add("https://github.com/axsk/PCCA.jl")`
"""
using SparseArrays
using LinearAlgebra
using PCCA
using MAT
using NPZ
file = "/data/numerik/ag_cmd/anPraktikantin/ratesStep01.txt"
data = reduce(hcat, (split.(readlines(file), ',')))
i = parse.(Int, data[1, :]) .- 30000000 .+ 1
j = parse.(Int, data[2, :]) .- 30000000 .+ 1
v = parse.(Float64, data[3, :])
Q = sparse(i, j, v)
Q[diagind(Q)] .= 0
Q[diagind(Q)] .= -sum(Q, dims=2)
p = ones(size(Q, 1))
n = 4
solver = PCCA.ArnoldiSolver()
optim = true
X, lam = PCCA.schurvectors(Q, p, n, optim, solver)
chi = PCCA.makeprobabilistic(X, true)
write = false
if write
matwrite("out/ratesStep01.mat", Dict("Q" => Q, "X" => X, "chi" => chi))
matwrite("out/ratesStep01_withoutQ.mat", Dict("X" => X, "chi" => chi))
npzwrite("out/ratesStep01_withoutQ.npz", Dict("X" => X, "chi" => chi))
end