Skip to content
GraphEdgeCount

GraphEdgeCount

Description

Number of directed edges currently stored in graph. Includes edges marked for removal but not yet committed.

Parameters

Name Direction Description
g in Graph to query.

Success

Returns the edge count as a u64. The graph is not modified.

Failure

Function cannot fail.

Usage example (Cross-references)

Usage examples (Cross-references)
        *GraphNodeDataPtr(&graph, node_b) = 25;
    
        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;
        // are read directly here to verify the default-constructed graph has
        // every internal cursor / table empty.
        bool result = GraphNodeCount(&graph) == 0 && GraphEdgeCount(&graph) == 0 && GraphEmpty(&graph) &&
                      VecBegin(&graph.slots) == NULL && VecBegin(&graph.free_indices) == NULL &&
                      VecBegin(&graph.pending_edge_removals) == NULL && GraphCopyInit(&graph) == NULL &&
        result = result && (removed == 1);
        result = result && (GraphNodeCount(&graph) == 2);
        result = result && (GraphEdgeCount(&graph) == 1);
        result = result && !GraphContainsNode(&graph, b);
        result = result && (GraphOutDegree(&graph, a) == 0);
        result = result && GraphHasEdge(&graph, a, c);
        result = result && !GraphHasEdge(&graph, b, c);
        result = result && (GraphEdgeCount(&graph) == 1);
        result = result && (GraphOutDegree(&graph, a) == 1);
        result = result && (GraphInDegree(&graph, b) == 0);
        result      = result && (GraphCommitChanges(&graph) == 0);
        result      = result && GraphHasEdge(&graph, a, b);
        result      = result && (GraphEdgeCount(&graph) == 1);
    
        GraphDeinit(&graph);
        result      = result && GraphMarkEdgeForRemoval(&graph, a, a);
        result      = result && (GraphCommitChanges(&graph) == 1);
        result      = result && (GraphEdgeCount(&graph) == 0);
        result      = result && (GraphOutDegree(&graph, a) == 0);
        result      = result && (GraphInDegree(&graph, a) == 0);
        result      = result && !GraphContainsNode(&graph, b);
        result      = result && (GraphNodeCount(&graph) == 3);
        result      = result && (GraphEdgeCount(&graph) == 0);
        result      = result && (GraphOutDegree(&graph, a) == 0);
        result      = result && (GraphOutDegree(&graph, d) == 0);
        GraphClear(&graph);
    
        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 && GraphAddEdge(&graph, a, c);
        result      = result && !GraphAddEdge(&graph, a, b);
        result      = result && GraphEdgeCount(&graph) == 2;
        result      = result && GraphOutDegree(&graph, a) == 2;
        result      = result && GraphInDegree(&graph, a) == 0;
        result      = result && GraphAddEdge(&graph, c, a);
        result      = result && !GraphAddEdge(&graph, a, a);
        result      = result && (GraphEdgeCount(&graph) == 3);
        result      = result && (GraphOutDegree(&graph, a) == 1);
        result      = result && (GraphInDegree(&graph, a) == 3);
Last updated on