Skip to main content

edge_partition

Function edge_partition 

Source
pub fn edge_partition(
    condensed_graph: &Graph,
    partition: &NodePartition,
) -> EdgePartition
Expand description

Returns the edge partition that goes with the node partition partition, from the edges of the partitioned graph to the edges of condensed_graph.

The edges from group g to group h all map to the condensed edge g -> h, which is edge condensed_graph.edge_index_of(g, h). EdgePartition::edges_of lists them, and the reduce functions of the result combine their data. An edge inside a group, or from or to a node in no group, maps to None. Here, by_package groups the methods of a program by package. Its condensed graph package_calls holds the calls between packages (see NodePartition::of). by_package_call tells which calls between methods are behind the call from service to model:

let by_package_call = graphs::edge_partition(&package_calls, &by_package);
let service_to_model = package_calls.edge_index_of(service, model).unwrap();
let behind = by_package_call.edges_of(service_to_model);
// behind: [5, 7] - the calls load -> parse and save -> format

condensed_graph must be partition.condense(); only its node count is checked.

Time: O(node_count + edge_count log max_out_degree), with the node and edge count of the partitioned graph and the out-degrees of condensed_graph. Memory: up to 12 bytes per edge of the partitioned graph for the result.

ยงPanics

With an invalid argument message if condensed_graph.node_count() is not partition.group_count().