link_id_t TripleMultiNetwork::doAddLink(const node_id_t source,
		const node_id_t target)
{
	const link_id_t l = TypedNetwork<NodeType, LinkType>::doAddLink(source,
			target);

	// create a new triple for each adjacent link of source (except the newly created one)
	NeighborLinkIteratorRange siters = neighborLinks(source);
	for (NeighborLinkIterator& it = siters.first; it != siters.second; ++it)
	{
		if (*it == l)
			continue;
		addTriple(l, *it);
	}

	// now do the same for each adjacent link of target
	NeighborLinkIteratorRange titers = neighborLinks(target);
	for (NeighborLinkIterator& it = titers.first; it != titers.second; ++it)
	{
		if (*it == l)
			continue;
		addTriple(l, *it);
	}
	return l;
}
bool TripleMultiNetwork::doChangeLink(const link_id_t l,
		const node_id_t source, const node_id_t target)
{
	bool retval = true, source_changed = false, target_changed = false;
	if (link(l).source() != source)
	{
		removeTriplesFromLinkEnd(l, true);
		source_changed = true;
	}
	if (link(l).target() != target)
	{
		removeTriplesFromLinkEnd(l, false);
		target_changed = true;
	}

	// now change the link, updating its state
	retval &= TypedNetwork<NodeType, LinkType>::doChangeLink(l, source, target);

	// and add the newly created triples accordingly
	if (source_changed)
	{
		NeighborLinkIteratorRange iters = neighborLinks(source);
		for (NeighborLinkIterator& it = iters.first; it != iters.second; ++it)
		{
			if (*it == l)
				continue;
			addTriple(l, *it);
		}
	}
	if (target_changed)
	{
		NeighborLinkIteratorRange iters = neighborLinks(target);
		for (NeighborLinkIterator& it = iters.first; it != iters.second; ++it)
		{
			if (*it == l)
				continue;
			addTriple(l, *it);
		}
	}
	return retval;
}
Exemple #3
0
void prune(hashTable** oldT, hashTable** newT, triple*** oldA, triple*** newA, long u){

	//build new hashtable skipping values if need to be pruned
	//keep one char 
	//keep strs at leased used times
	//non empty prefix?
	int newPref[(*oldT)->num_triples];

	for(int j = 0; j < (*oldT)->num_triples; j++) {
		if((*oldA)[j]->pref == SPECIAL || (*oldA)[j]->pref == EMPTY) {
				newPref[j] = (*newT)->num_triples;
				addTriple((*newA), (*newT), (*oldA)[j]->c, (*oldA)[j]->pref);
		} else if ((*oldA)[j]->used  >= u) {
			//lookup value at location of old pref
				//add the new code as the value at the old code


// oldA  [[code: 0, c:c, pref:0], [code: 1, c:a, pref:0],[code: 2, c:b, pref:0],[code: 3, c:a, pref:1],[code: 4, c:b, pref:1]]

// newPref [[oldcode 0, newcode:-2], [old]]

			//at old code put new location
				newPref[j] = (*newT)->num_triples;
				addTriple((*newA), (*newT), (*oldA)[j]->c, newPref[(*oldA)[j]->pref]);

			//send the code locaiton in old array and the new location

		} 
	}


	freeTable((*oldT));
	freeArray(*oldA);


	(*oldA) = (*newA);
	(*oldT) = (*newT);

}