network_id MultipleNetwork::addNetwork(std::string network_name, Network& net) {
	if (containsNetwork(network_name)) throw DuplicateElementException("network " + network_name);
	network_id new_network_id = addNetwork(net);
	network_name_to_id[network_name] = new_network_id;
	network_id_to_name.push_back(network_name);
	return new_network_id;
}
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;
}
Exemple #3
0
vertex_id Network::addVertex(const std::string& vertex_name) {
	if (containsVertex(vertex_name)) throw DuplicateElementException("Vertex " + vertex_name + " already exists");
	if (!isNamed()) throw OperationNotSupportedException("Cannot add a named vertex to an unnamed network");
	max_vertex_id++;
	vertex_id new_vertex_id = max_vertex_id;
	vertexes.insert(new_vertex_id);
	vertex_id_to_name[new_vertex_id] = vertex_name;
	vertex_name_to_id[vertex_name] = new_vertex_id;
	return new_vertex_id;
}
global_vertex_id MultipleNetwork::addVertex(std::string name) {
	global_vertex_id new_vertex_id;
	if (vertex_name_to_id.count(name)>0) {
		throw DuplicateElementException("vertex " + name);
	}
	else {
		int num_current_vertexes = getNumVertexes();
		new_vertex_id = addVertex();
		vertex_name_to_id[name] = num_current_vertexes;
		vertex_id_to_name.push_back(name);
	}
	return new_vertex_id;
}
global_identity MultiplexNetwork::addGlobalName(const std::string& name) {
	global_identity new_identity;
	if (identity_name_to_id.count(name)>0) {
		throw DuplicateElementException("vertex " + name);
	}
	else {
		int num_current_identities = getNumGlobalIdentities();
		new_identity = addGlobalIdentity();
		identity_name_to_id[name] = num_current_identities;
		identity_id_to_name[new_identity] = name;
	}
	return new_identity;
}
Exemple #6
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());
}
Exemple #7
0
void Network::newStringEdgeAttribute(const std::string& attribute_name) {
	if (edge_string_attribute.count(attribute_name)>0) throw DuplicateElementException("Attribute " + attribute_name);
	edge_string_attribute[attribute_name] = std::map<edge_id,std::string>();
}
Exemple #8
0
void Network::newNumericEdgeAttribute(const std::string& attribute_name) {
	if (edge_numeric_attribute.count(attribute_name)>0) throw DuplicateElementException("Attribute " + attribute_name);
	edge_numeric_attribute[attribute_name] = std::map<edge_id,double>();
}
Exemple #9
0
void Network::newStringVertexAttribute(const std::string& attribute_name) {
	if (vertex_string_attribute.count(attribute_name)>0) throw DuplicateElementException("Attribute " + attribute_name);
	vertex_string_attribute[attribute_name] = std::map<vertex_id,std::string>();
}
void MultiplexNetwork::newNumericAttribute(const std::string& attribute_name) {
	if (numeric_attribute.count(attribute_name)>0) throw DuplicateElementException("Attribute " + attribute_name);
	numeric_attribute[attribute_name] = std::map<vertex_id,double>();
}