@@ -57,26 +57,43 @@ create_edges <- function(list_split){
5757 small_tibble $ spanning }))
5858 })
5959 list_desc_links <- nested_crois %> % map(function (big_tibble ) {
60- # Condition for clusters that only have one table
60+ # Only compare the spanning variables for clusters that have more than 1 table
6161 if (length(big_tibble $ table_name ) > 1 ) {
6262 spannings_nom_tab <- combn(big_tibble $ table_name , 2 , FUN = list )
63-
6463 tab_to_keep <- map(spannings_nom_tab , function (crois ) {
64+ # Extract the first table (Ta) corresponding to the first table of the
65+ # pair of tables we are studying
6566 Ta <- big_tibble %> % filter(table_name == crois [[1 ]])
67+ # Get the 'spanning' column for Ta
6668 crois_Ta <- Ta $ spanning [[1 ]]
69+
70+ # Extract the first table (Tb) corresponding to the second table of the
71+ # pair of tables we are studying
6772 Tb <- big_tibble %> % filter(table_name == crois [[2 ]])
73+ # Get the 'spanning' column for Tb
6874 crois_Tb <- Tb $ spanning [[1 ]]
75+
76+ # Create an empty data frame to store origin → destination relationships
6977 df_origin_dest <- data.frame (from = character (), to = character (), stringsAsFactors = FALSE )
78+
79+ # Check if all elements of Ta are included in Tb
7080 if (all(crois_Ta %in% crois_Tb )) {
81+ # Add a row indicating that Ta can go to Tb
7182 df_origin_dest <- rbind(df_origin_dest ,
72- data.frame (from = crois [[1 ]], to = crois [[2 ]],stringsAsFactors = FALSE ))
83+ data.frame (from = crois [[1 ]], to = crois [[2 ]], stringsAsFactors = FALSE ))
7384 }
85+
86+ # Check if all elements of Tb are included in Ta
7487 if (all(crois_Tb %in% crois_Ta )) {
88+ # Add a row indicating that Tb can go to Ta
7589 df_origin_dest <- rbind(df_origin_dest ,
7690 data.frame (from = crois [[2 ]], to = crois [[1 ]], stringsAsFactors = FALSE ))
7791 }
92+
93+ # Return the data frame containing possible links
7894 return (df_origin_dest )
7995 })
96+
8097 # Filter non empty tables and combine them
8198 tab_to_keep_compact <- tab_to_keep %> %
8299 purrr :: discard(is.null ) %> %
0 commit comments