GraphNeighborAt
Description
Access outgoing neighbor id at given offset.
Parameters
| Name | Direction | Description |
|---|---|---|
g |
in | Graph to query. |
node_id |
in | Source node id. |
neighbor_idx |
in | Index in outgoing neighbor list. |
Failure
Does not return on invalid node id or out-of-bounds neighbor index.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Graph.Ops.c:136:
result = result && (GraphInDegree(&graph, b) == 0);
result = result && (GraphInDegree(&graph, c) == 1);
result = result && (GraphNeighborAt(&graph, a, 0) == c);
result = result && (GraphPredecessorAt(&graph, c, 0) == a);- In
Graph.Ops.c:211:
result = result && (GraphOutDegree(&graph, a) == 1);
result = result && (GraphInDegree(&graph, a) == 1);
result = result && (GraphNeighborAt(&graph, a, 0) == a);
result = result && (GraphPredecessorAt(&graph, a, 0) == a);
result = result && GraphMarkEdgeForRemoval(&graph, a, a); result = result && GraphInDegree(&graph, b) == 1;
result = result && GraphInDegree(&graph, c) == 1;
result = result && GraphNeighborAt(&graph, a, 0) == b && GraphNeighborAt(&graph, a, 1) == c;
result = result && GraphNeighborAt(&graph, c, 0) == a;
result = result && GraphPredecessorAt(&graph, a, 0) == c; result = result && GraphInDegree(&graph, c) == 1;
result = result && GraphNeighborAt(&graph, a, 0) == b && GraphNeighborAt(&graph, a, 1) == c;
result = result && GraphNeighborAt(&graph, c, 0) == a;
result = result && GraphPredecessorAt(&graph, a, 0) == c;
result = result && GraphPredecessorAt(&graph, b, 0) == a;
static bool test_graph_neighbor_access_oob_deadend(void) {
WriteFmt("Testing GraphNeighborAt out-of-bounds access (should abort)\n");
typedef Graph(int) IntGraph;
GraphAddEdge(&graph, a, b);
(void)GraphNeighborAt(&graph, b, 0);
GraphDeinit(&graph); result = result && GraphInDegree(&graph, b) == 1;
result = result && GraphInDegree(&graph, c) == 1;
result = result && GraphNeighborAt(&graph, a, 0) == b;
result = result && GraphNeighborAt(&graph, a, 1) == c;
result = result && GraphPredecessorAt(&graph, b, 0) == a; result = result && GraphInDegree(&graph, c) == 1;
result = result && GraphNeighborAt(&graph, a, 0) == b;
result = result && GraphNeighborAt(&graph, a, 1) == c;
result = result && GraphPredecessorAt(&graph, b, 0) == a;
result = result && GraphPredecessorAt(&graph, c, 0) == a; result = result && (GraphOutDegree(&graph, a) == 1);
result = result && (GraphInDegree(&graph, a) == 3);
result = result && (GraphNeighborAt(&graph, a, 0) == a);
result = result && (GraphPredecessorAt(&graph, a, 0) == a);
result = result && (GraphPredecessorAt(&graph, a, 1) == b);
Last updated on