本文整理汇总了C++中Message::AddNodeToPath方法的典型用法代码示例。如果您正苦于以下问题:C++ Message::AddNodeToPath方法的具体用法?C++ Message::AddNodeToPath怎么用?C++ Message::AddNodeToPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::AddNodeToPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RoutePureGreedy
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();
}
示例2: ReceiveMessage
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;
}
示例3: RouteDijkstra
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();
}
示例4: RoutePureRandom
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();
}