예제 #1
0
edge_id Network::addEdge(const std::string& vertex_name1, const std::string& vertex_name2) {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vertex_name1)) throw ElementNotFoundException("Vertex " + vertex_name1);
	if (!containsVertex(vertex_name2)) throw ElementNotFoundException("Vertex " + vertex_name2);
	//std::cout << "Edge: " << vertex_name1 << " " << vertex_name_to_id[vertex_name1]
	//<< " " << vertex_name2 << " " << vertex_name_to_id[vertex_name2] << std::endl;
	return addEdge(vertex_name_to_id[vertex_name1],vertex_name_to_id[vertex_name2]);
}
예제 #2
0
void Network::setStringEdgeAttribute(vertex_id vid1, vertex_id vid2, const std::string& attribute_name, const std::string& val) {
	if (!containsVertex(vid1)) throw ElementNotFoundException("Vertex " + std::to_string(vid1));
	if (!containsVertex(vid2)) throw ElementNotFoundException("Vertex " + std::to_string(vid2));
	if (!containsEdge(vid1, vid2)) throw ElementNotFoundException("Edge (" + std::to_string(vid2) + ", " + std::to_string(vid2) + ")");
	if (edge_string_attribute.count(attribute_name)==0) throw ElementNotFoundException("Attribute " + attribute_name);
	edge_id eid(vid1, vid2, isDirected());
	edge_string_attribute.at(attribute_name)[eid] = val;
}
예제 #3
0
std::string Network::getStringEdgeAttribute(vertex_id vid1, vertex_id vid2, const std::string& attribute_name) const {
	if (!containsVertex(vid1)) throw ElementNotFoundException("Vertex " + std::to_string(vid1));
	if (!containsVertex(vid2)) throw ElementNotFoundException("Vertex " + std::to_string(vid2));
	if (!containsEdge(vid1, vid2)) throw ElementNotFoundException("Edge (" + std::to_string(vid1) + ", " + std::to_string(vid2) + ")");
	if (edge_string_attribute.count(attribute_name)==0) throw ElementNotFoundException("Attribute " + attribute_name);
	edge_id eid(vid1, vid2, isDirected());
	if (edge_string_attribute.at(attribute_name).count(eid)==0)  throw ElementNotFoundException("No attribute value for attribute " + attribute_name + " on edge (" + std::to_string(vid1) + "," +  std::to_string(vid2) + ")");
	return edge_string_attribute.at(attribute_name).at(eid);
}
void MultipleNetwork::map(global_vertex_id gvid, vertex_id lvid, int nid) {
	if (!containsVertex(gvid)) throw ElementNotFoundException("global vertex " + std::to_string(gvid));
	if (!containsNetwork(nid)) throw ElementNotFoundException("network " + std::to_string(nid));
	if (!getNetwork(nid)->containsVertex(lvid)) throw ElementNotFoundException("local vertex " + std::to_string(lvid));
	if (global_to_local_id[gvid].count(nid)>0) throw DuplicateElementException("global vertex " + std::to_string(gvid) + " in network " + std::to_string(nid));
	// We update the references between global and local identifiers
	global_to_local_id[gvid][nid] = lvid;
	local_to_global_id[nid][lvid] = gvid;
}
예제 #5
0
edge_id Network::addEdge(vertex_id vid1, vertex_id vid2) {
	if (!containsVertex(vid1)) throw ElementNotFoundException("Vertex " + std::to_string(vid1));
	if (!containsVertex(vid2)) throw ElementNotFoundException("Vertex " + std::to_string(vid2));
	if (out_edges[vid1].count(vid2)>0) throw DuplicateElementException("Edge (" + std::to_string(vid1) + "," + std::to_string(vid2) +  ") already exists");
	//max_edge_id++;
	out_edges[vid1].insert(vid2);
	in_edges[vid2].insert(vid1);
	if (!isDirected() && vid1!=vid2) {
		out_edges[vid2].insert(vid1);
		in_edges[vid1].insert(vid2);
	}
	if (isWeighted()) setNumericEdgeAttribute(vid1,vid2,"weight",MULTIPLENETWORK_DEFAULT_WEIGHT); // this value will be replaced if this method has been called inside addEdge(vertex_id, vertex_id, double)
	num_edges++;
	return edge_id(vid1, vid2, isDirected());
}
예제 #6
0
//NO USAR PARA BUSCAR EL HERMANO
KeyInt LeafNode::getFirstKey(){
        //puede que este vacio entonces devuelveo
        if(this->elements.size()==0){
                throw ElementNotFoundException();
        }
        return (*(elements.begin()))->getKey();
}
예제 #7
0
std::set<std::string> Network::getInNeighbors(const std::string& vertex_name) const  {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vertex_name)) throw ElementNotFoundException("Vertex " + vertex_name);
	std::set<std::string> neighbors;
	std::set<vertex_id> tmp_id_result = getInNeighbors(vertex_name_to_id.at(vertex_name));
	for (std::set<vertex_id>::iterator it=tmp_id_result.begin(); it!=tmp_id_result.end(); it++)
		neighbors.insert(vertex_id_to_name.at(*it));
	return neighbors;
}
예제 #8
0
std::set<vertex_id> Network::getInNeighbors(vertex_id vid) const  {
	std::set<vertex_id> neighbors;
	if (!containsVertex(vid)) throw ElementNotFoundException("Vertex " + std::to_string(vid));
	std::set<vertex_id>::const_iterator it;
	if (in_edges.count(vid)!=0)
		for (it=in_edges.at(vid).begin(); it!=in_edges.at(vid).end(); it++)
			neighbors.insert(*it);
	return neighbors;
}
예제 #9
0
void PaloExceptionFactory::raise(unsigned int errorCode, const std::string& shortText, const std::string& longText)
{

	if (errorCode < 0) {
		throw PaloServerException(longText, shortText, errorCode);
	} else {
		switch (errorCode) {
			case ERROR_DATABASE_NOT_FOUND:
				throw DatabaseNotFoundException(longText, shortText);

			case ERROR_DIMENSION_NOT_FOUND:
				throw DimensionNotFoundException(longText, shortText);

			case ERROR_ELEMENT_NOT_FOUND:
				throw ElementNotFoundException(longText, shortText);

			case ERROR_CUBE_NOT_FOUND:
				throw CubeNotFoundException(longText, shortText);

			case ERROR_SERVER_TOKEN_OUTDATED:
				throw ServerTokenOutdatedException(longText, shortText);

			case ERROR_DATABASE_TOKEN_OUTDATED:
				throw DatabaseTokenOutdatedException(longText, shortText);

			case ERROR_DIMENSION_TOKEN_OUTDATED:
				throw DimensionTokenOutdatedException(longText, shortText);

			case ERROR_CUBE_TOKEN_OUTDATED:
				throw CubeTokenOutdatedException(longText, shortText);

			default:
				throw PaloServerException(longText, shortText, errorCode);
		}
	}
	// TODO Exception does a strdup?
	std::string unknown("Unknown exception requested from factory! (");
	unknown.append(longText).append(")");
#if defined(WIN32) || defined(WIN64)
	throw std::exception( unknown.c_str() );
#else
	throw std::exception();
#endif
}
예제 #10
0
void Network::setNumericVertexAttribute(vertex_id vid, const std::string& attribute_name, double val) {
	if (vertex_numeric_attribute.count(attribute_name)==0) throw ElementNotFoundException("Attribute " + attribute_name);
	vertex_numeric_attribute.at(attribute_name)[vid] = val;
}
std::string MultipleNetwork::getNetworkName(network_id nid) {
	if (!containsNetwork(nid)) throw ElementNotFoundException("network " + std::to_string(nid));
	return network_id_to_name[nid];
}
예제 #12
0
double Network::getNumericEdgeAttribute(const std::string& vertex_name1, const std::string& vertex_name2, const std::string& attribute_name) const {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vertex_name1)) throw ElementNotFoundException("Vertex " + vertex_name1);
	if (!containsVertex(vertex_name2)) throw ElementNotFoundException("Vertex " + vertex_name2);
	return getNumericEdgeAttribute(vertex_name_to_id.at(vertex_name1), vertex_name_to_id.at(vertex_name2), attribute_name);
}
예제 #13
0
std::string Network::getStringVertexAttribute(vertex_id vid, const std::string& attribute_name) const {
	if (vertex_string_attribute.count(attribute_name)==0) throw ElementNotFoundException("Attribute " + attribute_name);
	if (vertex_string_attribute.at(attribute_name).count(vid)==0)  throw ElementNotFoundException("No attribute value for attribute " + attribute_name + " on vertex " + std::to_string(vid));
	return vertex_string_attribute.at(attribute_name).at(vid);
}
Network* MultipleNetwork::getNetwork(std::string network_name) {
	if (!containsNetwork(network_name)) throw ElementNotFoundException("network " + network_name);
	return &(networks[network_name_to_id[network_name]]);
}
예제 #15
0
void Network::setStringEdgeAttribute(const std::string& vertex_name1, const std::string& vertex_name2, const std::string& attribute_name, const std::string& val) {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vertex_name1)) throw ElementNotFoundException("Vertex " + vertex_name1);
	if (!containsVertex(vertex_name2)) throw ElementNotFoundException("Vertex " + vertex_name2);
	setStringEdgeAttribute(vertex_name_to_id.at(vertex_name1), vertex_name_to_id.at(vertex_name2), attribute_name, val);
}
network_id MultipleNetwork::getNetworkId(std::string network_name) {
	if (network_name_to_id.count(network_name)==0) throw ElementNotFoundException("network " + network_name);
	return network_name_to_id[network_name];
}
예제 #17
0
double MLNetwork::get_weight(const NodeSharedPtr& node1, const NodeSharedPtr& node2) {
	EdgeSharedPtr edge = get_edge(node1,node2);
	if (!edge) throw ElementNotFoundException("edge between " + node1->to_string() + " and " + node2->to_string());
	return edge_features(node1->layer,node2->layer)->getNumeric(edge->id,DEFAULT_WEIGHT_ATTR_NAME);
}
global_vertex_id MultipleNetwork::getGlobalVertexId(vertex_id lvid, network_id nid) {
	if (!getNetwork(nid)->containsVertex(lvid)) throw ElementNotFoundException("local vertex " + std::to_string(lvid) + " in network " + std::to_string(nid));
	return local_to_global_id[nid][lvid];
}
vertex_id MultipleNetwork::getLocalVertexId(global_vertex_id gvid, network_id nid) {
	if (!containsVertex(gvid,nid)) throw ElementNotFoundException("global vertex " + std::to_string(gvid) + " in network " + std::to_string(nid));
	return global_to_local_id[gvid][nid];
}
Network* MultipleNetwork::getNetwork(network_id nid) {
	if (!containsNetwork(nid)) throw ElementNotFoundException("network " + std::to_string(nid));
	return &(networks[nid]);
}
std::string MultipleNetwork::getVertexName(global_vertex_id gvid) {
	if (!containsVertex(gvid)) throw ElementNotFoundException("global vertex id " + std::to_string(gvid));
	return vertex_id_to_name[gvid];
}
예제 #22
0
void Network::setStringVertexAttribute(vertex_id vid, const std::string& attribute_name, const std::string& val) {
	if (vertex_string_attribute.count(attribute_name)==0) throw ElementNotFoundException("Attribute " + attribute_name);
	vertex_string_attribute.at(attribute_name)[vid] = val;
}
void MultipleNetwork::map(std::string global_vertex_name, std::string local_vertex_name, std::string network_name) {
	if (!containsVertex(global_vertex_name)) throw ElementNotFoundException("global vertex name " + global_vertex_name);
	if (!getNetwork(network_name)->containsVertex(local_vertex_name)) throw ElementNotFoundException("local vertex name " + local_vertex_name);
	if (!containsNetwork(network_name)) throw ElementNotFoundException("network " + network_name);
	map(getVertexId(global_vertex_name),getNetwork(network_name)->getVertexId(local_vertex_name),getNetworkId(network_name));
}
예제 #24
0
global_identity MultiplexNetwork::getGlobalIdentity(vertex_id lvid, network_id nid) const {
	if (!getNetwork(nid).containsVertex(lvid)) throw ElementNotFoundException("local vertex " + std::to_string(lvid) + " in network " + std::to_string(nid));
	return local_to_global_id.at(global_vertex_id(lvid,nid));
}
예제 #25
0
std::string Network::getVertexName(vertex_id vid) const  {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vid)) throw ElementNotFoundException("Vertex " + std::to_string(vid));
	return vertex_id_to_name.at(vid);
}
global_vertex_id MultipleNetwork::getVertexId(std::string global_vertex_name) {
	if (!containsVertex(global_vertex_name)) throw ElementNotFoundException("global vertex name " + global_vertex_name);
	return vertex_name_to_id[global_vertex_name];
}
예제 #27
0
edge_id Network::addEdge(const std::string& vertex_name1, const std::string& vertex_name2, double weight) {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vertex_name1)) throw ElementNotFoundException("Vertex " + vertex_name1);
	if (!containsVertex(vertex_name2)) throw ElementNotFoundException("Vertex " + vertex_name2);
	return addEdge(vertex_name_to_id[vertex_name1],vertex_name_to_id[vertex_name2], weight);
}
예제 #28
0
vertex_id Network::getVertexId(const std::string& vertex_name) const  {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vertex_name)) throw ElementNotFoundException("Vertex " + vertex_name);
	return vertex_name_to_id.at(vertex_name);
}
예제 #29
0
long Network::getInDegree(vertex_id vid) const  {
	if (!containsVertex(vid)) throw ElementNotFoundException("Vertex " + std::to_string(vid));
	if (in_edges.count(vid)==0) return 0;
	return in_edges.at(vid).size();
}
예제 #30
0
vertex_id MultiplexNetwork::getVertexId(global_identity gvid, network_id nid) const {
	if (!containsVertex(gvid,nid)) throw ElementNotFoundException("global identity " + std::to_string(gvid) + " in network " + std::to_string(nid));
	return global_to_local_id.at(gvid).at(nid);
}