Skip to content
GraphMarkEdgeForRemoval

GraphMarkEdgeForRemoval

Description

Mark a directed edge for removal on the next GraphCommitChanges.

This operation is safe during traversal and does not structurally mutate the graph until commit.

Parameters

Name Direction Description
g in,out Graph owning the edge.
from in Source node id.
to in Destination node id.

Success

true when the edge was newly marked.

Failure

false when the edge is absent or was already marked.

Usage example (Cross-references)

Usage examples (Cross-references)
    
    static bool test_graph_mark_edge_for_removal(void) {
        WriteFmt("Testing GraphMarkEdgeForRemoval and deferred edge commit\n");
    
        typedef Graph(int) IntGraph;
                GraphNodeForeachNeighbor(node, neighbor) {
                    if (GraphNodeGetId(neighbor) == b) {
                        (void)GraphMarkEdgeForRemoval(&graph, GraphNodeGetId(node), GraphNodeGetId(neighbor));
                    }
                }
    
        bool result = GraphHasEdge(&graph, a, b);
        result      = result && GraphMarkEdgeForRemoval(&graph, b, c);
        result      = result && !GraphMarkEdgeForRemoval(&graph, b, c);
        result      = result && !GraphMarkEdgeForRemoval(&graph, c, b);
        bool result = GraphHasEdge(&graph, a, b);
        result      = result && GraphMarkEdgeForRemoval(&graph, b, c);
        result      = result && !GraphMarkEdgeForRemoval(&graph, b, c);
        result      = result && !GraphMarkEdgeForRemoval(&graph, c, b);
        result      = result && GraphMarkEdgeForRemoval(&graph, b, c);
        result      = result && !GraphMarkEdgeForRemoval(&graph, b, c);
        result      = result && !GraphMarkEdgeForRemoval(&graph, c, b);
    
        u64 committed = GraphCommitChanges(&graph);
    
        bool result = !GraphEdgeMarkedForRemoval(&graph, a, b);
        result      = result && GraphMarkEdgeForRemoval(&graph, a, b);
        result      = result && GraphEdgeMarkedForRemoval(&graph, a, b);
        result      = result && !GraphMarkEdgeForRemoval(&graph, a, b);
        result      = result && GraphMarkEdgeForRemoval(&graph, a, b);
        result      = result && GraphEdgeMarkedForRemoval(&graph, a, b);
        result      = result && !GraphMarkEdgeForRemoval(&graph, a, b);
        result      = result && GraphUnmarkEdgeForRemoval(&graph, a, b);
        result      = result && !GraphEdgeMarkedForRemoval(&graph, a, b);
        GraphAddEdge(&graph, a, c);
    
        bool result = GraphMarkEdgeForRemoval(&graph, a, b);
        result      = result && GraphMarkEdgeForRemoval(&graph, a, c);
        result      = result && GraphEdgeMarkedForRemoval(&graph, a, b);
    
        bool result = GraphMarkEdgeForRemoval(&graph, a, b);
        result      = result && GraphMarkEdgeForRemoval(&graph, a, c);
        result      = result && GraphEdgeMarkedForRemoval(&graph, a, b);
        result      = result && GraphEdgeMarkedForRemoval(&graph, a, c);
        result      = result && (GraphNeighborAt(&graph, a, 0) == a);
        result      = result && (GraphPredecessorAt(&graph, a, 0) == a);
        result      = result && GraphMarkEdgeForRemoval(&graph, a, a);
        result      = result && (GraphCommitChanges(&graph) == 1);
        result      = result && (GraphEdgeCount(&graph) == 0);
        GraphAddEdge(&graph, d, b);
    
        bool result = GraphMarkEdgeForRemoval(&graph, a, b);
        result      = result && GraphMarkNodeForDeletion(GraphGetNode(&graph, b));
        result      = result && GraphEdgeMarkedForRemoval(&graph, a, b);
        result = result && (GraphNodeVisit(GraphGetNode(&graph, first_id)) == 1);
        result = result && GraphMarkNodeForDeletion(GraphGetNode(&graph, second_id));
        result = result && GraphMarkEdgeForRemoval(&graph, third_id, third_id);
    
        GraphClear(&graph);
Last updated on