Traversal and structure
The traversal methods (neighbors, in_neighbors, out_neighbors,
successors, predecessors) are methods of the graph:
anet.neighbors('EGFR'). The functions in annnet.algorithms answer questions
about the directed edges of a graph.
annnet.algorithms.traversal.Traversal
Local neighborhood traversal over the incidence-backed graph.
Every method here delegates to the structural query facade of the core, which owns the traversal itself. The facade answers a binary edge from the adjacency index in time proportional to the degree, and it answers a hyperedge from a list it caches against the structural clock. A graph with no hyperedge therefore never pays a full edge scan.
Functions
neighbors
Return adjacent entities for a node or an edge-entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_id
|
str
|
Entity identifier. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Neighbor identifiers reachable through incident edges. |
out_neighbors
Return outward neighbors of a node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_id
|
str
|
Node identifier. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Neighbor identifiers reachable via outgoing or undirected edges. |
successors
Alias for :meth:out_neighbors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_id
|
str
|
Node identifier. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Successor identifiers. |
in_neighbors
Return inward neighbors of a node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_id
|
str
|
Node identifier. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Neighbor identifiers reachable via incoming or undirected edges. |
Structure
annnet.algorithms.structure.directed_pairs
Yield (source_id, target_id) for every directed binary edge.
An undirected edge has two sides in storage order and no direction, so it is left out. A hyperedge has no single source and no single target, so it is left out too, as are edges incident to edge entities. Ids are bare node ids, whatever layer the node sits in.
annnet.algorithms.structure.directed_cycle
One directed cycle, as the nodes along it, or None when there is none.
Depth-first over the directed binary edges, stopping at the first cycle
found. The list starts and ends on the same node, so a self-loop comes back
as [node, node]. Which cycle is found when there are several is not
promised.