Function removeNode

Synopsis

#include <Source/Falcor/Utils/Algorithm/DirectedGraph.h>

std::unordered_set< uint32_t > removeNode(uint32_t id)

Description

Remove a node from the graph. This function will also remove all the incoming and outgoing edges associated with the node

Returns
A list of edges that were removed

Source

Lines 62-82 in Source/Falcor/Utils/Algorithm/DirectedGraph.h.

std::unordered_set<uint32_t> removeNode(uint32_t id)
{
    if (mNodes.find(id) == mNodes.end())
    {
        logWarning("Can't remove node from DirectGraph, node ID doesn't exist");
        return {};
    }
    std::unordered_set<uint32_t> removedEdges;
    // Find all the edges we need to remove
    for (auto& edgeId : mNodes[id].mIncomingEdges) findEdgesToRemove<false>(mNodes[mEdges[edgeId].mSrc].mOutgoingEdges, id, removedEdges);
    for (auto& edgeId : mNodes[id].mOutgoingEdges) findEdgesToRemove<true>(mNodes[mEdges[edgeId].mDst].mIncomingEdges, id, removedEdges);
    // Remove them
    for (auto& edgeId : removedEdges) removeEdge(edgeId);
    // Remove the index from the map
    mNodes.erase(id);

    return removedEdges;
}





Add Discussion as Guest

Log in