Qu

has_edge

Builtin index · Collections & strings

result = neighbors(g, name)

Input: g, name · Output: result

What it is

g is a graph handle; name/a/b are node ids. has_edge(g, a, b) returns a bool; neighbors(g, name) returns a List of Str node ids. Ask about the graph: whether two nodes are joined, and what one node is joined to.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = neighbors(g, name)
g —g is a graph handle.
name —name/a/b are node ids.
result List
Returns a Bool from has_edge, and a List of node ids from neighbors.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

h = graph()
add_node(h, "X")          # an isolated node, no edges yet

h.add_edge("X", "Y")
print(has_edge(h, "X", "Y"))   # true

print(has_edge(h, "X", "Z"))   # false -- Z isn't even a node

print(neighbors(h, "X"))       # ("Y")

output
true
false
("Y")

from collections-strings

How it works

graph([directed=]) (§ data structures pass, 2026-09-01, algorithm, Dijkstra's shortest_path; see that module's own doc comment for the node-id normalization rule and why Dijkstra over plain BFS.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.

See also

neighbors — documented in the same entry.