Skip to main content

transposed_edge_mapping

Function transposed_edge_mapping 

Source
pub fn transposed_edge_mapping(graph: &Graph) -> EdgeMapping
Expand description

Returns the edge mapping from the transposed graph of graph to graph.

Edge e of BiAdjacentGraph::of(&graph).transposed() maps to the edge of graph it reverses: the transposed graph keeps the node IDs, but not the edge indices. The mapping is total, and its gather functions carry data on the edges over to the transposed graph. Here, site_count holds the number of call sites of each call by edge index of calls, and the counts follow the calls to the transposed graph, which lists the callers of parse:

let called_by = BiAdjacentGraph::of(&calls).transposed();
let called_by_site_count =
    graphs::transposed_edge_mapping(&calls).gather(&site_count);
for edge in called_by.out_edge_start(parse)..called_by.out_edge_end(parse) {
    writeln!(
        out,
        "{}: {}",
        names[called_by.edge_target(edge) as usize],
        called_by_site_count[edge as usize]
    )?;
}
// load: 1
// parse: 2

BiAdjacentGraph::transposed_edge_index translates a single edge, in the opposite direction.

Time: O(node_count + edge_count). Memory: 4 x edge_count bytes for the result; while it runs, 4 x node_count bytes more.