ARLClustering - Testing Facebook L1 Organization dataset

library(arlclustering)
#library(igraph)

Dataset description

The Facebook L1 organization social network dataset is a gml file, containing 5793 nodes and 45266 edges.

Loading network dataset

# Start the timer
t1 <- system.time({
  dataset_path <- system.file("extdata", "Facebook_Org_L1.gml", package = "arlclustering")
  if (dataset_path == "") {
    stop("Facebook_Org_L1.gml file not found")
  }
  
  g <- arlc_get_network_dataset(dataset_path, "Facebook L1 Organization")
  g$graphLabel
  g$totalNodes
  g$totalEdges
  g$averageDegree
})

# Display the total processing time
message("Graph loading Processing Time: ", t1["elapsed"], " seconds\n")
#> Graph loading Processing Time: 0.360999999999999 seconds

Generate Transactions

Next, we generate transactions from the graph, with a total rows of 3541.

# Start the timer
t2 <- system.time({
  transactions <- arlc_gen_transactions(g$graph)
  transactions
})

# Display the total processing time
message("Transaction dataset Processing Time: ", t2["elapsed"], " seconds\n")
#> Transaction dataset Processing Time: 2.795 seconds

Get Apriori Thresholds

We obtain the apriori thresholds for the generated transactions. The following are the thresholds for the apriori execution: - The Minimum Support : 0.002 - The Minimum Confidence : 0.5 - The Lift : 442.625 - The Gross Rules length : 97825 - The selection Ratio : 28

# Start the timer
t3 <- system.time({
  params <- arlc_get_apriori_thresholds(transactions,
                                        supportRange = seq(0.002, 0.003, by = 0.001),
                                        Conf = 0.5)
  params$minSupp
  params$minConf
  params$bestLift
  params$lenRules
  params$ratio
})

# Display the total processing time
message("Graph loading Processing Time: ", t3["elapsed"], " seconds\n")
#> Graph loading Processing Time: 0.189 seconds

Generate Gross Rules

We use the obtained parameters to generate gross rules, where we obtain 97858 rules.

# Start the timer
t4 <- system.time({
  minLenRules <- 1
  maxLenRules <- params$lenRules
  if (!is.finite(maxLenRules) || maxLenRules > 5*length(transactions)) {
    maxLenRules <- 5*length(transactions)
  }
  
  grossRules <- arlc_gen_gross_rules(transactions,
                                     minSupp = params$minSupp,
                                     minConf = params$minConf,
                                     minLenRules = minLenRules+1,
                                     maxLenRules = maxLenRules)
  grossRules$TotalRulesWithLengthFilter
})
#> Apriori
#> 
#> Parameter specification:
#>  confidence minval smax arem  aval originalSupport maxtime support minlen
#>         0.5    0.1    1 none FALSE            TRUE       5   0.002      2
#>  maxlen target  ext
#>   17705  rules TRUE
#> 
#> Algorithmic control:
#>  filter tree heap memopt load sort verbose
#>     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
#> 
#> Absolute minimum support count: 7 
#> 
#> set item appearances ...[0 item(s)] done [0.00s].
#> set transactions ...[5713 item(s), 3541 transaction(s)] done [0.01s].
#> sorting and recoding items ... [952 item(s)] done [0.00s].
#> creating transaction tree ... done [0.00s].
#> checking subsets of size 1 2 3 4 5 6 7 8 9 10 11 done [0.05s].
#> writing ... [97858 rule(s)] done [0.03s].
#> creating S4 object  ... done [0.03s].
# Display the total number of clusters and the total processing time
message("Gross rules generation Time: ", t4["elapsed"], " seconds\n")
#> Gross rules generation Time: 0.166 seconds

Filter Significant and Non-Redundant Rules

We filter out redundant rules from the generated gross rules. Next, we filter out non-significant rules from the non-redundant rules, and we obtain the 18907 rule items.

t5 <- system.time({
  NonRedRules <- arlc_get_NonR_rules(grossRules$GrossRules)
  NonRSigRules <- arlc_get_significant_rules(transactions,
                                             NonRedRules$FiltredRules)
  NonRSigRules$TotFiltredRules
})
# Display the total number of clusters and the total processing time
message("\nClearing rules Processing Time: ", t5["elapsed"], " seconds\n")
#> 
#> Clearing rules Processing Time: 4.496 seconds

Clean and genarate final Rules

We clean the final set of rules to prepare for clustering. Then, we generate clusters based on the cleaned rules. The total identified clusters is 190 clusters.

t6 <- system.time({
  cleanedRules <- arlc_clean_final_rules(NonRSigRules$FiltredRules)
  clusters <- arlc_generate_clusters(cleanedRules)
  clusters$TotClusters
})
# Display the total number of clusters and the total processing time
message("Cleaning final rules Processing Time: ", t6["elapsed"], " seconds\n")
#> Cleaning final rules Processing Time: 1.624 seconds

message("The total comsumed time is:",t1["elapsed"]+ t2["elapsed"]+t3["elapsed"]+t4["elapsed"]+t5["elapsed"]+t6["elapsed"], "seconds\n")
#> The total comsumed time is:9.631seconds

Plot Clusters

Finally, we visualize the identified clusters.

arlc_clusters_plot(g$graph,
                   g$graphLabel,
                   clusters$Clusters)
#> 
#> Total Identified Clusters: 190
#>  =========================
#>   Community 01:3 19 23 36 37 144 5286
#>   Community 02:6 1753
#>   Community 03:7 1905 2642 3976
#>   Community 04:8 1853
#>   Community 05:11 60 375 376 378 379 380 381 382 383 385 387 390 391 397 398 399 400 408 1005 1020 1029 1037 1044 1053 1054 1055 1064 1769
#>   Community 06:16 60
#>   Community 07:18 401
#>   Community 08:19 23 36 37 1747
#>   Community 09:22 46
#>   Community 10:37 1747 1758
#>   Community 11:49 60
#>   Community 12:60 1753
#>   Community 13:62 1004 1061 2236
#>   Community 14:82 553 560
#>   Community 15:83 87 95 98 100 104 107 552 553 590 639 656 658 944 960 962 1641 1737 2181
#>   Community 16:85 89 92 566 568 653 949 950 955 961 963 964
#>   Community 17:89 566 637 644 653 949 955 964 2520
#>   Community 18:92 566 568 653 949 955 961 963 964 1479
#>   Community 19:96 553 962
#>   Community 20:108 120 2287 3144
#>   Community 21:111 120 989 2287 2956 2961
#>   Community 22:144 392 402 988 989 990 1747 1755 1758 1809 1817 2226 2233 2235 2250 2337 2528 2992 3008 3021 3153 3829 3834 4298
#>   Community 23:157 167 188 241
#>   Community 24:160 171
#>   Community 25:161 163 171 173 185 186 192 208 220 713 780 876 1100 1103 1111 1215 1321 1374 1510
#>   Community 26:163 170 171 173 181 184 185 192 208 213 219 220 481 693 713 780 876 1100 1215 1216 1321 1374 1510 1537
#>   Community 27:164 185 186 192
#>   Community 28:166 185 481 780
#>   Community 29:167 179 180 187 188 210 231 241 605 702 718 864 1094 1122 1378 1402
#>   Community 30:171 173 181 183 184 185 186 192 219 220 276 478 481 525 693 698 713 714 717 719 721 780 859 860 870 1100 1103 1215 1243
#>   Community 31:172 185
#>   Community 32:174 185
#>   Community 33:177 185
#>   Community 34:178 185
#>   Community 35:179 180 187 188 210 216 222 225 231 241 874 976 1122 1123 1378 1402 1531
#>   Community 36:181 185 186 220 525 693 713 717 780 859 1100 1103 1509
#>   Community 37:185 186 191 192 207 208 212 213 217 219 220 223 224 226 234 269 270 273 275 276 279 285 478 479 481 489 525 547 610 619 621 626 630 693 694 695 698 700 705 706 708 709 713 714 716 717 719 720 721 749 780 835 859 860 876 917 1100 1103 1111 1121 1215 1243 1374 1434 1508 1510
#>   Community 38:187 188 210 231 241 605 976 1094 1122 1123 1378
#>   Community 39:188 210 216 228 231 233 241 362 605 702 718 864 918 976 1094 1112 1122 1123 1378 1383 1402 1531
#>   Community 40:191 630 695 700 701 703 706 709 716 717 835 840
#>   Community 41:208 213 215 219 220 224 236 713 876 1100 1111 1215 1216 1374 1405 1537
#>   Community 42:210 216 222 225 227 228 231 233 241 265 314 362 605 696 699 702 712 718 740 741 834 864 874 1077 1083 1094 1112 1122 1123 1139 1146 1272 1276 1279 1286 1378 1383 1397 1402 1503 1515 1525 1528 1531 1545 1547 1648 2036 2451 2576
#>   Community 43:214 713 862
#>   Community 44:215 876 1536 1600 1601
#>   Community 45:216 222 225 227 228 231 233 237 241 605 702 718 864 869 874 918 1083 1094 1122 1123 1378 1383 1402 1491 1515 1531
#>   Community 46:219 220 224 236 481 713 719 749 780 859 860 876 1100 1103 1111 1374
#>   Community 47:220 223 224 236 276 478 479 481 525 539 547 693 698 713 719 721 749 780 859 860 862 876 1100 1103 1111 1215 1374
#>   Community 48:223 481 547 694 695 713 749 780 2410
#>   Community 49:226 270 273 917 2410
#>   Community 50:227 228 233 241 265 277 280 287 605 702 718 1076 1077 1078 1079 1083 1094 1122 1402 1531 1797
#>   Community 51:228 231 233 237 241 265 605 702 718 864 869 1076 1077 1083 1094 1107 1122 1123 1242 1402 1504 1531 1797 2274
#>   Community 52:233 241 265 280 605 702 1076 1077 1078 1079 1083 1094 1122 1123 1402 1531 1797 2275
#>   Community 53:241 362 605 702 718 864 874 918 976 1083 1094 1107 1112 1122 1123 1242 1327 1378 1383 1396 1402 1491 1515 1531 1795 1797
#>   Community 54:265 277 280 287 605 777 1077 1083 1094 1242 1397 2273 2275 2451
#>   Community 55:267 279
#>   Community 56:268 602
#>   Community 57:276 489 547 695 713 714 719 1091 1103
#>   Community 58:344 358 364 369
#>   Community 59:346 350 354 356 357 360 365 368 515 520 728 740 750 755 757 761 1262
#>   Community 60:347 348 349 352 353 355 358 359 363 364 367 369 370 519 522 524 738 743 748 751 753 758
#>   Community 61:358 359 363 364 367 369 370 371 522 523 524 525 738 743 748 751 753 758
#>   Community 62:362 1122 1378 1396 2171 3079
#>   Community 63:363 364 367 369 370 519 522 524 525 738 743 751 753
#>   Community 64:369 370 371 372 519 522 523 524 525 730 738 743 748 751 753 758
#>   Community 65:373 392 402 407 988 989 990 1033 1747 1755 1758 2337 2528 2742 2956 3021 3023 3150 3153 3157 3393
#>   Community 66:374 380 382 386 399 400 408 1005 1064 3011 3029
#>   Community 67:378 381 382 391 399 1005 1021 1029 1055
#>   Community 68:380 381 382 386 395 397 398 399 400 403 408 1005 1029 1037 1053 1054 1055 1064 1410 2994 3002 3011 3022 3029
#>   Community 69:381 382 385 386 395 397 398 399 400 403 408 1005 1008 1020 1029 1047 1053 1054 1055 1064 1913 2499 2968 2994 3002 3011 3029
#>   Community 70:382 383 385 386 387 391 395 397 398 399 400 403 408 1002 1004 1005 1010 1014 1018 1020 1021 1028 1029 1037 1040 1043 1047 1053 1054 1055 1061 1064 1068 1769 2999 3002 3011 3029
#>   Community 71:383 387 390 391 398 399 405 1020 1029 1044 1753
#>   Community 72:386 395 399 400 403 408 1005 1037 1410 2994 3002 3011 3022 3029 3154
#>   Community 73:390 391 399 1006 1750 1762 1769
#>   Community 74:392 402 407 988 989 990 1747 1751 2233 2337 2528 2956 2961 2992 3021 3022 3023 3150 3153 3157 3393
#>   Community 75:396 2246
#>   Community 76:397 399 1005 1008 1020 1029 1053 1054 1055 1410 2243 2724 2968 3002 3011
#>   Community 77:399 400 403 408 1005 1010 1014 1020 1021 1029 1037 1044 1047 1053 1054 1055 1061 1064 1068 1769 3002 3011 3029
#>   Community 78:400 403 408 1005 1037 1064 1410 2499 3002 3011 3029
#>   Community 79:402 407 988 989 990 1033 1643 1747 1751 1755 1758 1764 2233 2337 2528 2742 2958 2961 2992 3008 3021 3153 3157 3393 3591
#>   Community 80:408 1005 1037 1055 1410 2994 3002 3011 3022 3029 3208
#>   Community 81:515 520 728 740 741 750 755 757 761 1146 1262 1286 1503 1545 1547
#>   Community 82:525 539 713 717 721 735 748 749 780 1100 1103 1121 1215
#>   Community 83:532 616 754 780 1246 1532
#>   Community 84:533 540 735 1134 1135
#>   Community 85:534 566 585 588 880 909 1496 1887
#>   Community 86:537 1525 1533
#>   Community 87:538 754 756 771 773 778 1143 1428 1470 2054
#>   Community 88:540 541 543 735 778 1134 1135 1143 1147 1148 1308 1428
#>   Community 89:541 1134 1147 1269 1312
#>   Community 90:546 1143 1428
#>   Community 91:553 560 569 658 944 960 962 1476 2181
#>   Community 92:566 568 588 592 637 644 653 939 949 950 955 961 963 964 1335 2043 2513 2515 2520
#>   Community 93:585 890 909
#>   Community 94:588 653 939 1128 1129 1335 1338 1354
#>   Community 95:605 696 702 712 718 864 1077 1083 1094 1107 1108 1122 1123 1242 1378 1402 1504 1515 1516 1531
#>   Community 96:637 644 653 949 950 955 963 964 1128 1335 1354 2043 2513 2515 2520
#>   Community 97:638 641 656 658
#>   Community 98:641 648 652 656 658 956
#>   Community 99:653 949 950 955 961 963 964 1335 1479 2043 2513 2515 2520
#>   Community 100:655 656
#>   Community 101:656 658 945 952 956
#>   Community 102:658 944 956 1336 1342 1348 1353 1356
#>   Community 103:695 700 701 703 705 706 709 713 716 717 720 835 840
#>   Community 104:696 699 702 712 718 834 845 846 1094 1146
#>   Community 105:702 712 718 864 1083 1094 1122 1123 1242 1402 1504 1515 2274 2275
#>   Community 106:708 1520
#>   Community 107:713 714 717 719 720 721 749 780 859 860 862 876 1091 1100 1103 1121 1215 1216 1219 1374 1510 1537
#>   Community 108:717 835 840 1103
#>   Community 109:718 834 845 846 864 1094 1112 1122 1123 1146 1402 1515
#>   Community 110:736 746
#>   Community 111:741 750 939 1129 1272 1276 1278 1286 1293 1310 1323 1525 1528 1545 2036
#>   Community 112:754 773 1134 1135 1143 1428 1532
#>   Community 113:772 1135
#>   Community 114:773 1135 1143 1144 1428
#>   Community 115:777 1286 1397 1496 1499 1525 1533 1547 1648 2451
#>   Community 116:780 859 860 862 1100 1103 1215 1246 1510
#>   Community 117:859 860 862 870 1100 1103 1117 1509
#>   Community 118:862 1100 1495
#>   Community 119:864 869 1094 1122 1123 1402 1504 1515 2274
#>   Community 120:874 1086 1122 1123 1402 1491 1585 1587 1588 1594
#>   Community 121:881 939 1129
#>   Community 122:939 1128 1129 1334 1335 1338 1354 1558 1886 2159 2160
#>   Community 123:946 956
#>   Community 124:948 956
#>   Community 125:975 1377
#>   Community 126:983 1741
#>   Community 127:988 989 990 1033 1747 1755 1758 2226 2233 2235 2250 2337 2528 2742 2956 2958 2961 2992 3008 3021 3150 3153 3157 3393 4298
#>   Community 128:989 990 1033 1040 1747 1751 1755 1758 2226 2233 2235 2250 2337 2488 2528 2731 2738 2742 2956 2958 2961 2992 3008 3021 3023 3150 3153 3157 3388 3393 3914 3976 4298 4346 5286
#>   Community 129:1004 1018 1021 1031 1043 1047 1053 1061 1068 2230 2231 2232 2234 2236 2239 2241 2248 2249 2251 3389
#>   Community 130:1018 1031 1037 1043 1047 1053 1060 1061 1068 2230 2231 2236 2241 2248 2249 2251 3389
#>   Community 131:1021 1028 1029 1043 1047 1053 1061 1066
#>   Community 132:1040 1055 1061 1064 2488 2956 2958 2961
#>   Community 133:1044 1054 1753
#>   Community 134:1045 1054
#>   Community 135:1053 1055 1061 1068 2231 2232 2236 2241 2249
#>   Community 136:1094 1122 1123 1242 1244 1376 1378 1402 1504 1515 1516 1531 2273 2274 2275
#>   Community 137:1100 1103 1111 1215 1374 1510 1537
#>   Community 138:1104 2273
#>   Community 139:1108 1279 1286 1547
#>   Community 140:1121 1377
#>   Community 141:1126 1336 1348 1349 1351 1353 1356 1535 1554
#>   Community 142:1134 1135 1143 1147 1269 1312 1652
#>   Community 143:1135 1143 1144 1148 1425 1428 1470 1543 1546
#>   Community 144:1265 1312
#>   Community 145:1276 1278 1286 1293 1310 1323 1503 1525 1528 1545 1934 2036
#>   Community 146:1279 1286 1323 1503 1525 1545 1547
#>   Community 147:1286 1293 1310 1323 1499 1503 1525 1528 1533 1545 1547 1648 1876 1934 2036
#>   Community 148:1293 1323 1327
#>   Community 149:1311 1331
#>   Community 150:1327 1329 2168 2539
#>   Community 151:1342 1348 1349 1353 1356 1357
#>   Community 152:1349 1351 1353 1356 1357 1535 1554
#>   Community 153:1359 2697
#>   Community 154:1367 1741 1744
#>   Community 155:1378 1383 1396 2171 3079
#>   Community 156:1410 2499 2994 3002 3011 3029
#>   Community 157:1412 1413 2211 3278 3296
#>   Community 158:1413 2206 2211 3278 3296
#>   Community 159:1463 1466
#>   Community 160:1474 1655
#>   Community 161:1486 4823
#>   Community 162:1525 1528 1533 1545 1547 1648 1934 2036 2141
#>   Community 163:1577 1585 1587
#>   Community 164:1588 1594 2665
#>   Community 165:1604 1817 1821 3834
#>   Community 166:1747 1751 1755 1758 1764 2337 2528 2956 2958 2961 3008 3021 3153 3157
#>   Community 167:1750 1753 1762
#>   Community 168:1753 1762 1769
#>   Community 169:1755 1758 1764 2337 2643 2956 2958 2961 3591
#>   Community 170:1760 2282
#>   Community 171:1809 1817 1864 2488 3362 3829 3834 4628 4677
#>   Community 172:1813 1836 1871 2046 2050 2673
#>   Community 173:1814 1863 1864
#>   Community 174:1817 1820 1821 1863 1864 2488 3362 3829 3834 4628 4677
#>   Community 175:1829 1864 4628
#>   Community 176:2036 2142
#>   Community 177:2045 2046 2050
#>   Community 178:2092 3365
#>   Community 179:2290 3389
#>   Community 180:2304 2306 3892 3893 4171
#>   Community 181:2329 2330
#>   Community 182:2330 3261
#>   Community 183:2488 2731 2956 2958 2961 3829 3834 3976
#>   Community 184:2667 3829
#>   Community 185:2725 2738
#>   Community 186:2741 2958
#>   Community 187:3022 3023 3029
#>   Community 188:3023 3102 3150 3153 3157 3393
#>   Community 189:3144 3892 3893
#>   Community 190:3153 3157 3190 3393
#>  =========================