| 91 | } |
| 92 | |
| 93 | bool DenseBFSGraph::tryAddParentWithWeight(nodeID_t boundNodeID, relID_t edgeID, nodeID_t nbrNodeID, |
| 94 | bool fwdEdge, double weight, ObjectBlock<ParentList>* block) { |
| 95 | ParentList* expected = getParentListHead(nbrNodeID.offset); |
| 96 | auto parent = reserveParent(boundNodeID, edgeID, fwdEdge, block); |
| 97 | parent->setCost(getParentListHead(boundNodeID)->getCost() + weight); |
| 98 | while (true) { |
| 99 | if (parent->getCost() < getCost(expected)) { |
| 100 | // New parent has smaller cost, erase all existing parents and add new parent. |
| 101 | if (curData[nbrNodeID.offset].compare_exchange_strong(expected, parent)) { |
| 102 | parent->setNextPtr(nullptr); |
| 103 | return true; |
| 104 | } |
| 105 | } else if (parent->getCost() == getCost(expected) && expected->getEdgeID() != edgeID) { |
| 106 | // New parent has the same cost and comes from different edge, |
| 107 | // append new parent as after existing parents. |
| 108 | if (curData[nbrNodeID.offset].compare_exchange_strong(expected, parent)) { |
| 109 | parent->setNextPtr(expected); |
| 110 | return true; |
| 111 | } |
| 112 | } else { |
| 113 | block->revertLast(); |
| 114 | return false; |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | bool DenseBFSGraph::tryAddSingleParentWithWeight(nodeID_t boundNodeID, relID_t edgeID, |
| 120 | nodeID_t nbrNodeID, bool fwdEdge, double weight, ObjectBlock<ParentList>* block) { |
no test coverage detected