Function ben::utils::sort_json_file_by_key
source · pub fn sort_json_file_by_key<R: Read, W: Write>(
reader: R,
writer: W,
key: &str
) -> Result<HashMap<usize, usize>>Expand description
Sorts a JSON-formatted NetworkX graph file by a key. This function will sort the nodes in the graph by the key provided and then relabel the nodes in the graph from 0 to n-1 where n is the number of nodes in the graph. It will also relabel the edges in the graph to match the new node labels.
§Arguments
reader- A reader for the JSON file to sort.writer- A writer for the new JSON file.key- The key to sort the nodes by.
§Returns
A Result containing a HashMap from the old node labels to the new node labels.