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
Returns true when node_id currently refers to a live node (slot occupied, generation matching, and not yet committed for deletion). The graph is not modified.
Failure
Returns false when the id refers to a freed or stale slot (mismatched generation). The graph is not modified.
Usage example (Cross-references)
Usage examples (Cross-references)
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;- In
Graph.Type.c:49:
result = result && GraphNodeGetId(node) == node_id;
result = result && GraphNodeIndex(node) == 0;
result = result && GraphContainsNode(&graph, node_id);
GraphDeinit(&graph);- In
Graph.Ops.c:55:
}
bool result = GraphContainsNode(&graph, b) && (graph.pending_delete_count == 1);
u64 removed = GraphCommitChanges(&graph);- In
Graph.Ops.c:61:
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);- In
Graph.Ops.c:99:
result = result && !GraphUnmarkNodeForDeletion(node);
result = result && (GraphCommitChanges(&graph) == 0);
result = result && GraphContainsNode(&graph, a);
result = result && (GraphNodeCount(&graph) == 1);- In
Graph.Ops.c:267:
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);- In
Graph.Ops.c:298:
bool result = GraphMarkNodeForDeletion(GraphGetNode(&graph, b));
result = result && (GraphCommitChanges(&graph) == 1);
result = result && !GraphContainsNode(&graph, b);
GraphNodeId reused = GraphAddNodeR(&graph, 99);- In
Graph.Init.c:43:
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);
// intentional bypass: no public accessors for `slots`, `free_indices`,
- In
Graph.Init.c:44:
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);
// intentional bypass: no public accessors for `slots`, `free_indices`,
// `pending_delete_count`, or `pending_edge_removals`; this test asserts
Last updated on