class Place::Router::Digraph(N, E)
- Place::Router::Digraph(N, E)
- Reference
- Object
Overview
Labelled digraph. Holds node labels of type N and edge labels of type E.
Nodes are stored on UInt64 ID's. This provides an interface that should feel
similar to Indexable
for interacting with nodes labels. Similarly edges can
be placed and retrieved by using a dual index of {predescessor, successor}.
OPTIMIZE replace with a sparse matrix and graphBLAS operations.
Defined in:
place/router/digraph.crConstructors
Instance Method Summary
-
#[](pred_id, succ_id)
Retrieves the label attached to the edge that joins pred_id and succ_id.
-
#[](id)
Retrieves the label attached to node id.
-
#[]=(pred_id, succ_id, attr)
Inserts an edge.
-
#[]=(id, attr)
Insert a new node.
-
#breadth_first_search(from, & : UInt64 -> Bool | Nil)
Perform a breadth first search across the graph, starting at from.
- #clear(*args, **options)
- #clear(*args, **options, &)
-
#fetch(pred_id, succ_id, &) : E
Retrieves the label attached to the edge that joins pred_id and succ_id.
-
#fetch(id, &) : N
Retrieves the label attached to node id.
-
#indegree(id)
The number of incomming edges to id.
-
#insert(pred_id, succ_id, attr : E, &)
Inserts an edge.
-
#insert(id, attr : N, &)
Inserts a node.
-
#nodes : Enumerable(UInt64)
Provides all nodes present within the graph.
-
#outdegree(id)
The outgoing edges from id.
-
#path(from, to, invert = false) : Enumerable(UInt64) | Nil
Returns a list of node IDs that form the shortest path between the passed nodes or
nil
if no path exists. -
#sink?(id) : Bool
Checks if a node has incoming edges only.
-
#sinks : Enumerable(UInt64)
Provides all nodes with incoming edges only.
-
#source?(id) : Bool
Checks if a node has outgoing edges only.
-
#sources : Enumerable(UInt64)
Provides all nodes with outgoing edges only.
-
#subtree(id) : Enumerable(UInt64)
Provides all nodes reachable from id.
Constructor Detail
Instance Method Detail
Perform a breadth first search across the graph, starting at from.
Each node id is yielded as it's traversed. The search will terminate when
this block returns true. If nil
is returned the node is skipped, but the
traversal continues.
Results are provided as a Hash that includes all reached nodes as the keys, and their predecessor as the associated value.
Retrieves the label attached to the edge that joins pred_id and succ_id.
Provides all nodes present within the graph.
NOTE ordering of nodes is not defined.
Returns a list of node IDs that form the shortest path between the passed
nodes or nil
if no path exists.
Provides all nodes with outgoing edges only.
OPTIMIZE this is very slow [O(V * E)], but works for testing purposes. Switching the sparse matrix should assist so not worth optimising for this setup.