GraphClear
Description
Remove all nodes and edges from the graph but keep allocated storage. Node payloads are deinitialized via the configured copy_deinit handler when present.
Parameters
| Name | Direction | Description |
|---|---|---|
g |
in,out | Graph handle. |
Success
Returns to the caller. live_count, edge_count, and the pending-delete count are now 0. Every node slot is marked free; every adjacency list is reset. When copy_deinit is configured it has been invoked on each previously-stored payload. The slot array and free-index array keep their allocated capacity.
Failure
Function cannot fail.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Ops.c:387:
// succeeds.
static bool test_graph_clear_resets_free_slot_visit_count(void) {
WriteFmt("Testing GraphClear resets free-slot visit_count\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Ops.c:403:
(void)a;
GraphClear(&graph);
// A valid op after clear runs ValidateGraph; on the mutant the pre-free
- In
Ops.c:422:
// deletion).
static bool test_graph_clear_empties_free_indices(void) {
WriteFmt("Testing GraphClear empties free_indices before repopulating\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Ops.c:437:
result = result && (GraphCommitChanges(&graph) == 1);
GraphClear(&graph);
// Valid op runs ValidateGraph; on the mutant free_indices is over-long and
- In
Init.c:16:
static bool test_graph_reserve_clear(void) {
WriteFmt("Testing GraphReserve and GraphClear\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Init.c:45:
result = result && GraphMarkEdgeForRemoval(&graph, third_id, third_id);
GraphClear(&graph);
result = result && GraphNodeCount(&graph) == 0 && GraphEdgeCount(&graph) == 0 && GraphEmpty(&graph);- In
Foreach.c:507:
// code aborts on the next iteration step.
static bool test_graph_clear_during_traversal_aborts_deadend(void) {
WriteFmt("Testing GraphClear during traversal invalidates iterator (should abort)\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Foreach.c:523:
// Structural mutation mid-iteration: the next iterator step must
// detect the epoch change and abort.
GraphClear(&graph);
}
visited += 1;
Last updated on