Ejemplo n.º 1
0
void * IxSqlQueryBuilder::existIdX(long lIndex, const QVariant & idOwner, const QVariant & idData)
{
   QString sIdOwner = idOwner.toString(); QString sIdData = idData.toString();
   if (! m_pIdX || sIdOwner.isEmpty() || sIdData.isEmpty()) { qAssert(false); return NULL; }
   if ((lIndex < 0) || (lIndex >= m_pIdX->count())) { qAssert(false); return NULL; }

   type_id idX(sIdOwner, sIdData);
   type_ptr_by_id_ptr pHash = m_pIdX->at(lIndex);
   if (! pHash || ! pHash->contains(idX)) { return NULL; }

   return pHash->value(idX);
}
Ejemplo n.º 2
0
bool IxSqlQueryBuilder::insertIdX(long lIndex, const QVariant & idOwner, const QVariant & idData, void * ptr)
{
   QString sIdOwner = idOwner.toString(); QString sIdData = idData.toString();
   if (! m_pIdX || sIdOwner.isEmpty() || sIdData.isEmpty()) { qAssert(false); return false; }
   if ((lIndex < 0) || (lIndex >= m_pIdX->count())) { qAssert(false); return false; }

   type_id idX(sIdOwner, sIdData);
   type_ptr_by_id_ptr pHash = m_pIdX->at(lIndex);
   if (! ptr || ! pHash || pHash->contains(idX)) { qAssert(false); return false; }
   pHash->insert(idX, ptr);

   return true;
}
Ejemplo n.º 3
0
vector<int> slashBurn(Graph &graph, int K)
{
	//printGraph(graph);
    int p = 0, q = (int)graph.size() - 1;
    vector<int> weightsum(q + 1, 0);
    vector<int> idX(q + 1, 0), xId(q + 1, 0);
    for(int i = 0; i < q + 1; i++){
        idX[i] = xId[i] = i;
    }
    calcWeightSum(weightsum, graph);
    while(q - p + 1 > K){
		if(TKDE){
        /* TKDE: select topK in greedy way */
			for(int i = 0; i < K; i++, p++){
				int maxloc = select_biggest(weightsum, xId, p, q);
				remove_vertex_from_graph(graph, xId[maxloc], weightsum);
				iter_swap(idX.begin() + xId[p], idX.begin() + xId[maxloc]);
				iter_swap(xId.begin() + maxloc, xId.begin() + p);
			}
		}
		else{
		/* ICDM: select topK directly */
			vector<int> maxloc = select_topk(weightsum, xId, p, q, K);
			for(vector<int>::iterator it = maxloc.begin(); it != maxloc.end(); ++it, p++){
				remove_vertex_from_graph(graph, xId[*it], weightsum);
				iter_swap(idX.begin() + xId[p], idX.begin() + xId[*it]);
				iter_swap(xId.begin() + *it, xId.begin() + p);
			}
		}
		//Map or vector, trade-off between space and time
        vector<int> vertexCC(graph.size(), 0);
        vector<pair<int, int> > ccMetric(graph.size());
        find_cc(graph, p, q, xId, idX, vertexCC, ccMetric);
        vector<int> newx2X;
        int Q = sort_vertex(newx2X, vertexCC, ccMetric);
        if(Q == -1){
            break;
        }
        for(int i = Q; i < (int)newx2X.size(); i++){
            remove_vertex_from_graph(graph, xId[newx2X[i]], weightsum);
        }
        shuffle_vertex(newx2X, xId, idX, p);
        q = p + Q - 1;
    }
    return idX;
}