pub struct EdgeTypes { /* private fields */ }Expand description
The type of every edge of a graph in a depth-first search: tree, back, forward or cross edge, as
EdgeType defines them.
The types depend on the search. Uses a
depth-first search,
without recursion. The search starts at the nodes in ascending order and takes the out-nodes of
each node in ascending order, as DfsTraverser::run does.
type_of returns the type of one edge, and Edges::of
collects the edges of one type. Here, cfg is the control flow of a method with a loop and a
branch: the edge next -> header closes the loop, and body -> next skips then:
let types = EdgeTypes::of(&cfg);
let loop_edge = types.type_of(cfg.edge_index_of(next, header).unwrap());
let forward_edges = Edges::of(&types, EdgeType::Forward);
// loop_edge: Back
// forward_edges: body -> nextA graph is a DAG (directed acyclic graph) exactly if it has no back edge. For the back edges
alone, back_edges::of saves the classification of the other edges.
Instances are immutable and safe to share between threads (Send and Sync).
Memory: 1 byte per edge; an instance also shares the arrays of its graph.
Implementations§
Source§impl EdgeTypes
impl EdgeTypes
Sourcepub fn of(graph: &Graph) -> EdgeTypes
pub fn of(graph: &Graph) -> EdgeTypes
Returns the type of every edge of graph, from one depth-first search.
Time: O(node_count + edge_count). Memory: edge_count bytes for the result; while it runs, 4 bytes and 2 bits per node, and up to 8 x node_count bytes for the stack, which grows with the deepest path.
§Panics
With an invalid argument message if a depth-first path is longer than 2^30 - 5 nodes.