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)
- In
Ops.c:65:
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);- In
Ops.c:133:
}
bool result = GraphHasEdge(&graph, a, b);
result = result && GraphMarkEdgeForRemoval(&graph, b, c);
result = result && !GraphMarkEdgeForRemoval(&graph, b, c);- In
Ops.c:141:
result = result && (committed == 2);
result = result && !GraphHasEdge(&graph, a, b);
result = result && GraphHasEdge(&graph, a, c);
result = result && !GraphHasEdge(&graph, b, c);- In
Ops.c:142:
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);- In
Ops.c:143:
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);- In
Ops.c:177:
result = result && !GraphUnmarkEdgeForRemoval(&graph, a, b);
result = result && (GraphCommitChanges(&graph) == 0);
result = result && GraphHasEdge(&graph, a, b);
result = result && (GraphEdgeCount(&graph) == 1);- In
Ops.c:208:
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);- In
Ops.c:209:
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);- In
Ops.c:370:
result = result && GraphContainsNode(&graph, a);
result = result && GraphContainsNode(&graph, c);
result = result && GraphHasEdge(&graph, a, c);
result = result && (GraphOutDegree(&graph, a) == 1);
result = result && (GraphEdgeCount(&graph) == 1);- In
Access.c:59:
static bool test_graph_has_edge_query(void) {
WriteFmt("Testing GraphHasEdge\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Access.c:73:
GraphAddEdge(&graph, green, blue);
bool result = GraphHasEdge(&graph, red, green);
result = result && GraphHasEdge(&graph, green, blue);
result = result && !GraphHasEdge(&graph, blue, green);- In
Access.c:74:
bool result = GraphHasEdge(&graph, red, green);
result = result && GraphHasEdge(&graph, green, blue);
result = result && !GraphHasEdge(&graph, blue, green);
result = result && !GraphHasEdge(&graph, red, blue);- In
Access.c:75:
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);- In
Access.c:76:
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);- In
Access.c:284:
// a silent `false` instead of aborting on the caller bug.
static bool test_has_edge_rejects_invalid_destination_deadend(void) {
WriteFmt("Testing GraphHasEdge rejects an invalid destination id (should abort)\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Access.c:296:
GraphNodeId bogus_to = make_raw_node_id(5, 1);
(void)GraphHasEdge(&graph, a, bogus_to);
GraphDeinit(&graph);
Last updated on