pub struct Edges { /* private fields */ }Expand description
A list of edges of a graph, each with its source, target and edge index. Algorithms such as
back_edges::of and
Biconnectivity::bridges return it.
The edge at position p, in 0..count(), is source_nodes()[p] -> target_nodes()[p], and
edge_indices()[p] is its edge index in the graph the algorithm ran on. The edge index finds the
data of the edge in the caller’s arrays indexed by edge index, without a search. Here, the back
edges of the calls between the methods of a program are its recursive calls. names holds the
names of the methods, and site_count holds the number of call sites of each call, by edge index:
let recursive = back_edges::of(&calls);
for p in 0..recursive.count() as usize {
let caller = recursive.source_nodes()[p];
let callee = recursive.target_nodes()[p];
let edge = recursive.edge_indices()[p];
writeln!(
out,
"{} -> {}: {}",
names[caller as usize], names[callee as usize], site_count[edge as usize]
)?;
}
// parse -> parse: 2
// format -> format: 1Each function that returns Edges says in which order the edges come.
GraphBuilder::add_edges adds them to a graph under
construction.
The three lists are slices that cannot be modified - Java returns unmodifiable IntLists.
Instances are immutable and safe to share between threads (Send and Sync).
Memory: 12 bytes per edge.
Implementations§
Source§impl Edges
impl Edges
Sourcepub fn of(edge_types: &EdgeTypes, edge_type: EdgeType) -> Edges
pub fn of(edge_types: &EdgeTypes, edge_type: EdgeType) -> Edges
Returns the edges of one type from an edge classification, in edge index order.
Each call goes through every edge, however few have the type: call it once per type and keep the result.
Time: O(node_count + edge_count). Memory: 12 bytes per edge of the result.
Sourcepub fn source_nodes(&self) -> &[u32]
pub fn source_nodes(&self) -> &[u32]
Returns the source of each edge, by position.
Time: O(1).
Sourcepub fn target_nodes(&self) -> &[u32]
pub fn target_nodes(&self) -> &[u32]
Returns the target of each edge, by position.
Time: O(1).
Sourcepub fn edge_indices(&self) -> &[u32]
pub fn edge_indices(&self) -> &[u32]
Returns the edge index of each edge in the graph the algorithm ran on, by position.
Time: O(1).