Skip to content
GraphContainsNode

GraphContainsNode

Description

Check whether graph currently contains the provided node id.

Marked nodes still count as present until GraphCommitChanges is called. This is the safe probe to use before deciding whether an old stored id is still live.

Parameters

Name Direction Description
g in Graph to query.
node_id in Node id to check.

Success

true when node_id currently refers to a live node.

Failure

false

Usage example (Cross-references)

Usage examples (Cross-references)
        }
    
        bool result = GraphContainsNode(&graph, b) && (graph.pending_delete_count == 1);
        u64  removed = GraphCommitChanges(&graph);
        result = result && (GraphNodeCount(&graph) == 2);
        result = result && (GraphEdgeCount(&graph) == 1);
        result = result && !GraphContainsNode(&graph, b);
        result = result && (GraphOutDegree(&graph, a) == 0);
        result = result && (GraphInDegree(&graph, a) == 1);
        result      = result && !GraphUnmarkNodeForDeletion(node);
        result      = result && (GraphCommitChanges(&graph) == 0);
        result      = result && GraphContainsNode(&graph, a);
        result      = result && (GraphNodeCount(&graph) == 1);
        result      = result && GraphNodeMarkedForDeletion(GraphGetNode(&graph, b));
        result      = result && (GraphCommitChanges(&graph) == 2);
        result      = result && !GraphContainsNode(&graph, b);
        result      = result && (GraphNodeCount(&graph) == 3);
        result      = result && (GraphEdgeCount(&graph) == 0);
        bool result = GraphMarkNodeForDeletion(GraphGetNode(&graph, b));
        result      = result && (GraphCommitChanges(&graph) == 1);
        result      = result && !GraphContainsNode(&graph, b);
    
        GraphNodeId reused = GraphAddNodeR(&graph, 99);
    
        result = result && GraphNodeCount(&graph) == 0 && GraphEdgeCount(&graph) == 0 && GraphEmpty(&graph);
        result = result && !GraphContainsNode(&graph, first_id) && !GraphContainsNode(&graph, second_id);
        result = result && !GraphContainsNode(&graph, third_id);
        result = result && graph.slots.length == slot_count && graph.free_indices.length == slot_count;
        result = result && GraphNodeCount(&graph) == 0 && GraphEdgeCount(&graph) == 0 && GraphEmpty(&graph);
        result = result && !GraphContainsNode(&graph, first_id) && !GraphContainsNode(&graph, second_id);
        result = result && !GraphContainsNode(&graph, third_id);
        result = result && graph.slots.length == slot_count && graph.free_indices.length == slot_count;
        result = result && graph.slots.capacity == slot_capacity && graph.free_indices.capacity >= slot_count;
        result      = result && GraphNodeGetId(node) == node_id;
        result      = result && GraphNodeIndex(node) == 0;
        result      = result && GraphContainsNode(&graph, node_id);
    
        GraphDeinit(&graph);
    
        bool result = GraphNodeCount(&graph) == 3 && GraphEdgeCount(&graph) == 3 && !GraphEmpty(&graph);
        result      = result && GraphContainsNode(&graph, a) && GraphContainsNode(&graph, b) && GraphContainsNode(&graph, c);
        result      = result && GraphNodeAt(&graph, b) == 25;
        result      = result && GraphNodeData(&graph, node_b) == 25;
Last updated on