@@ -87,19 +87,34 @@ void Graph::alltopologicalSort(const std::string& output_directory,
8787// ' saves them to a specified output directory. It ensures the output directory exists
8888// ' and creates it if it does not.
8989// '
90- // ' @param prefs An integer matrix (`arma::umat`) representing the preference relations.
90+ // ' @param prefs A matrix representing the preference relations. This matrix
91+ // ' must have two columns, the first of which represents the preferred item
92+ // ' and the second of which represents the disfavored item.
9193// ' @param n_items An integer specifying the number of items to sort.
9294// ' @param output_directory A string specifying the directory where the output files will be saved.
9395// ' @param save_frac Number between 0 and 1 specifying which fraction of sorts to save.
9496// '
9597// ' @details
9698// ' The function generates all possible topological sorts for the provided preference matrix
97- // ' and saves each sort as a binary file in the specified output directory. The output files
98- // ' are named sequentially as `sort0.bin`, `sort1.bin`, and so on.
99+ // ' and saves approximately `save_frac` of the sorts as binary file in the specified output directory.
100+ // ' The output files are named sequentially as `sort0.bin`, `sort1.bin`, and so on.
99101// '
100102// ' @return This function returns the number of topological sorts.
101103// '
102104// ' @export
105+ // ' @examples
106+ // ' # Extract preferences from user 1 in the included example data.
107+ // ' prefs <- pairwise_preferences[
108+ // ' pairwise_preferences$user == 1, c("top_item", "bottom_item"), drop = FALSE]
109+ // '
110+ // ' # Count the number of sorts without saving them.
111+ // ' precompute_topological_sorts(
112+ // ' prefs = as.matrix(prefs),
113+ // ' n_items = 5,
114+ // ' output_directory = tempdir(),
115+ // ' save_frac = 0
116+ // ' )
117+ // '
103118// [[Rcpp::export]]
104119long long int precompute_topological_sorts (
105120 arma::umat prefs, int n_items, std::string output_directory, double save_frac) {
0 commit comments