Reference
db.neighbors
List the outgoing links of a record.
db.neighbors(id: str, type: str | None = None) -> list[tuple[str, str]]Parameters
Section titled “Parameters”-
id : str An existing record.
-
type : str, optional Only links of this type. Default
Nonereturns every type.
Returns
Section titled “Returns”(link_type, target id) tuples, sorted by type and then target.
Raises
Section titled “Raises”- ValueError
The id is unknown or
typeis not a valid link type name.
Examples
Section titled “Examples”import srvdb
db = srvdb.create("./vectors", dimension=128)vs = [[float(i == j) for j in range(128)] for i in range(3)]db.add(["a", "b", "c"], vs, ["{}"] * 3)db.link("a", "cites", "b")db.link("a", "about", "c")print(db.neighbors("a"))# [('about', 'c'), ('cites', 'b')]print(db.neighbors("a", type="cites"))# [('cites', 'b')]See also
Section titled “See also”- Links between records: Durability, delete and search expansion.
Was this page helpful? Tell us in Discussions.