use of cern.colt.matrix.tdouble.impl.SparseDoubleMatrix2D in project IR_Base by Linda-sunshine.
the class PageRank method constructSparseGraph.
private void constructSparseGraph(ArrayList<_Doc> collection) {
m_N = collection.size();
// we need to make this very sparse!
m_transition = new SparseDoubleMatrix2D(m_N, m_N);
// construct the connection
MyPriorityQueue<_RankItem> queue = new MyPriorityQueue<_RankItem>(m_topK);
for (int i = 0; i < collection.size(); i++) {
_Doc di = collection.get(i);
// find k-nearest neighbor
for (int j = 0; j < collection.size(); j++) {
if (i != j)
queue.add(new _RankItem(j, Utils.dotProduct(di, collection.get(j))));
}
// transition probability is proportion to similarity
double sum = 0;
for (_RankItem item : queue) {
item.m_value = Math.exp(item.m_value);
sum += item.m_value;
}
// set up the transition
for (_RankItem item : queue) // i -> j
m_transition.setQuick(i, item.m_index, item.m_value / sum);
queue.clear();
}
}
Aggregations