Exemplo n.º 1
0
bool Node::RoutePureGreedy(Message &m, string &nextNode) {
	if(!IsProp(INPATH))
		AddProp(INPATH);
	m.AddNodeToPath(Name); //Add Current node to path for tracking purposes only
	nextNode = GetClosestNeighborToNode(m.GetEndNode());
	return !nextNode.empty();
}
Exemplo n.º 2
0
bool Node::ReceiveMessage(Message &message) {
	if(message.GetEndNode() == Name) {
		message.AddNodeToPath(Name);
		return true;
	}
	else
		cout<<"ERROR: Node " << Name << " is not the destination node of this message..."<<endl;
	return false;
}
Exemplo n.º 3
0
bool Node::RouteDijkstra(Message &m, string &nextNode) {
	nextNode = "";
	m.AddNodeToPath(Name);
	if(m.Header_PrecomputedPath.size() > 0) {
		auto current = m.Header_PrecomputedPath.begin();
		if(*current == Name) {
			m.Header_PrecomputedPath.erase(current);
			nextNode = *m.Header_PrecomputedPath.begin();
		}
	}
	return !nextNode.empty();
}
Exemplo n.º 4
0
bool Node::RoutePureRandom(Message &m, string &nextNode) {
	nextNode = "";
	if(!IsProp(INPATH))
		AddProp(INPATH);
	m.AddNodeToPath(Name); //Add Current node to path for tracking purposes only
	string neighbor;
	if(Neighbors.size() > 1) {
		//srand((uint)time(NULL));
		auto it = Neighbors.begin();
		std::advance(it, rand() % Neighbors.size());
		neighbor = it->first;
	}
	else if(Neighbors.size() == 1)
		neighbor = Neighbors.begin()->first;

	return !nextNode.empty();
}