Skip to content

GraphHasEdge

Description

Check whether graph contains directed edge from -> to.

from and to must both be live node ids. This query treats stale ids as programmer error and aborts instead of quietly collapsing them to “not found”.

Parameters

Name Direction Description
g in Graph to query.
from in Source node id.
to in Destination node id.

Success

true when the directed edge exists.

Failure

false

Usage example (Cross-references)

Usage examples (Cross-references)
        result = result && (GraphInDegree(&graph, a) == 1);
        result = result && (GraphInDegree(&graph, c) == 0);
        result = result && GraphHasEdge(&graph, c, a);
        result = result && (GraphPredecessorAt(&graph, a, 0) == c);
        }
    
        bool result = GraphHasEdge(&graph, a, b);
        result      = result && GraphMarkEdgeForRemoval(&graph, b, c);
        result      = result && !GraphMarkEdgeForRemoval(&graph, b, c);
    
        result = result && (committed == 2);
        result = result && !GraphHasEdge(&graph, a, b);
        result = result && GraphHasEdge(&graph, a, c);
        result = result && !GraphHasEdge(&graph, b, c);
        result = result && (committed == 2);
        result = result && !GraphHasEdge(&graph, a, b);
        result = result && GraphHasEdge(&graph, a, c);
        result = result && !GraphHasEdge(&graph, b, c);
        result = result && (GraphEdgeCount(&graph) == 1);
        result = result && !GraphHasEdge(&graph, a, b);
        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 && !GraphUnmarkEdgeForRemoval(&graph, a, b);
        result      = result && (GraphCommitChanges(&graph) == 0);
        result      = result && GraphHasEdge(&graph, a, b);
        result      = result && (GraphEdgeCount(&graph) == 1);
        result      = result && GraphEdgeMarkedForRemoval(&graph, a, c);
        result      = result && (GraphCommitChanges(&graph) == 1);
        result      = result && GraphHasEdge(&graph, a, b);
        result      = result && !GraphHasEdge(&graph, a, c);
        result      = result && (GraphOutDegree(&graph, a) == 1);
        result      = result && (GraphCommitChanges(&graph) == 1);
        result      = result && GraphHasEdge(&graph, a, b);
        result      = result && !GraphHasEdge(&graph, a, c);
        result      = result && (GraphOutDegree(&graph, a) == 1);
        result      = result && (GraphInDegree(&graph, b) == 1);
    
    static bool test_graph_has_edge_query(void) {
        WriteFmt("Testing GraphHasEdge\n");
    
        typedef Graph(const char *) ZstrGraph;
        GraphAddEdge(&graph, green, blue);
    
        bool result = GraphHasEdge(&graph, red, green);
        result      = result && GraphHasEdge(&graph, green, blue);
        result      = result && !GraphHasEdge(&graph, blue, green);
    
        bool result = GraphHasEdge(&graph, red, green);
        result      = result && GraphHasEdge(&graph, green, blue);
        result      = result && !GraphHasEdge(&graph, blue, green);
        result      = result && !GraphHasEdge(&graph, red, blue);
        bool result = GraphHasEdge(&graph, red, green);
        result      = result && GraphHasEdge(&graph, green, blue);
        result      = result && !GraphHasEdge(&graph, blue, green);
        result      = result && !GraphHasEdge(&graph, red, blue);
        result      = result && (ZstrCompare(*GraphNodePtrAt(&graph, red), "red") == 0);
        result      = result && GraphHasEdge(&graph, green, blue);
        result      = result && !GraphHasEdge(&graph, blue, green);
        result      = result && !GraphHasEdge(&graph, red, blue);
        result      = result && (ZstrCompare(*GraphNodePtrAt(&graph, red), "red") == 0);
Last updated on