diff --git a/ocd/test/input/rdynGtCommunityMemberList.txt b/ocd/test/input/rdynGtCommunityMemberList.txt new file mode 100644 index 00000000..ae0c0e8f --- /dev/null +++ b/ocd/test/input/rdynGtCommunityMemberList.txt @@ -0,0 +1,7 @@ +1 [8, 9, 10, 11, 12, 13, 14, 15, 5, 91, 98, 95, 93] +3 [24, 25, 27, 30, 31, 33, 3, 6, 7, 82, 84, 92, 96, 16, 17, 18, 19, 23, 22, 20, 21] +4 [34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45] +6 [88, 83, 0, 94, 86, 81, 87, 97, 89, 99] +8 [85, 4, 80, 79, 1, 90, 53, 66, 69, 75, 76, 78] +9 [59, 46, 52, 56, 64, 63, 68, 58, 74, 51, 60, 57, 48, 61, 50, 55, 73, 67, 65, 47, 54, 62, 72, 71, 70, 49, 77] +11 [32, 2, 26, 29, 28] diff --git a/ocd/test/input/rdynGtGraph.txt b/ocd/test/input/rdynGtGraph.txt new file mode 100644 index 00000000..5915e095 --- /dev/null +++ b/ocd/test/input/rdynGtGraph.txt @@ -0,0 +1,785 @@ +0 1 + 0 91 +0 2 + 1 7 +0 3 + 2 22 +0 4 + 3 76 +0 5 + 4 99 +0 6 + 5 86 +0 7 + 6 30 +0 8 + 7 21 +0 9 + 8 14 +0 10 + 9 11 +0 11 + 10 14 +0 12 + 11 13 +0 13 + 12 14 +0 14 + 13 51 +0 15 + 14 52 +0 16 + 15 8 +0 17 + 16 32 +0 18 + 17 16 +0 19 + 18 16 +0 20 + 19 16 +0 21 + 20 21 +0 22 + 21 23 +0 23 + 22 32 +0 24 + 23 15 +0 25 + 24 28 +0 26 + 25 26 +0 27 + 26 33 +0 28 + 27 32 +0 29 + 28 27 +0 30 + 29 12 +0 31 + 30 71 +0 32 + 31 32 +0 33 + 32 25 +0 34 + 33 24 +0 35 + 34 11 +0 36 + 35 41 +0 37 + 36 44 +0 38 + 37 40 +0 39 + 38 22 +0 40 + 39 15 +0 41 + 40 34 +0 42 + 41 83 +0 43 + 42 37 +0 44 + 43 39 +0 45 + 44 27 +0 46 + 45 34 +0 47 + 46 27 +0 48 + 47 69 +0 49 + 48 53 +0 50 + 49 93 +0 51 + 50 20 +0 52 + 51 95 +0 53 + 52 48 +0 54 + 53 60 +0 55 + 54 51 +0 56 + 55 42 +0 57 + 56 20 +0 58 + 57 0 +0 59 + 58 46 +0 60 + 59 74 +0 61 + 60 25 +0 62 + 61 67 +0 63 + 62 78 +0 64 + 63 6 +0 65 + 64 58 +0 66 + 65 76 +0 67 + 66 60 +0 68 + 67 75 +0 69 + 68 53 +0 70 + 69 49 +0 71 + 70 74 +0 72 + 71 23 +0 73 + 72 48 +0 74 + 73 55 +0 75 + 74 60 +0 76 + 75 77 +0 77 + 76 37 +0 78 + 77 36 +0 79 + 78 48 +0 80 + 79 30 +0 81 + 80 14 +0 82 + 81 98 +0 83 + 82 31 +0 84 + 83 6 +0 85 + 84 11 +0 86 + 85 5 +0 87 + 86 56 +0 88 + 87 91 +0 89 + 88 11 +0 90 + 89 16 +0 91 + 90 78 +0 92 + 91 90 +0 93 + 92 83 +0 94 + 93 97 +0 95 + 94 4 +0 96 + 95 44 +0 97 + 96 87 +0 98 + 97 6 +0 99 + 98 86 +0 100 + 99 11 +1 100 - 2 22 +1 101 + 2 7 +1 101 - 3 76 +1 102 + 3 96 +1 102 - 5 85 +1 103 + 5 18 +1 103 - 6 30 +1 103 - 6 63 +1 103 - 6 83 +1 104 + 6 96 +1 104 - 7 21 +1 105 + 7 82 +1 106 + 82 95 +1 106 - 84 11 +1 107 + 84 3 +1 107 - 91 0 +1 107 - 91 87 +1 108 + 91 68 +1 108 - 92 83 +1 109 + 92 5 +1 110 + 93 96 +1 110 - 95 44 +1 111 + 95 93 +1 111 - 96 87 +1 112 + 96 84 +1 112 - 98 86 +1 113 + 98 6 +1 113 - 88 11 +1 114 + 88 4 +1 114 - 83 41 +1 115 + 83 80 +1 116 + 0 44 +1 117 + 85 86 +1 118 + 94 86 +1 119 + 86 4 +1 120 + 1 97 +1 120 - 79 30 +1 121 + 79 24 +1 122 + 4 81 +1 123 + 81 57 +1 124 + 90 0 +1 125 + 87 0 +1 126 + 97 88 +1 127 + 89 81 +1 127 - 80 14 +1 128 + 80 81 +1 129 + 99 79 +2 130 + 6 5 +2 130 - 2 7 +2 131 + 2 42 +2 131 - 3 84 +2 132 + 3 77 +2 133 + 5 3 +2 133 - 6 97 +2 134 + 7 5 +2 135 + 82 96 +2 136 + 84 12 +2 137 + 91 69 +2 138 + 92 33 +2 138 - 93 97 +2 139 + 93 91 +2 140 + 95 19 +2 140 - 98 81 +2 141 + 98 2 +2 141 - 88 4 +2 142 + 88 94 +2 143 + 83 77 +2 143 - 0 57 +2 143 - 0 90 +2 144 + 0 97 +2 145 + 85 94 +2 146 + 94 57 +2 147 + 86 64 +2 148 + 1 81 +2 148 - 79 24 +2 149 + 79 86 +2 149 - 4 81 +2 150 + 4 35 +2 151 + 81 88 +2 152 + 90 4 +2 153 + 87 99 +2 154 + 97 31 +2 154 - 89 16 +2 155 + 89 94 +2 156 + 80 10 +2 157 + 99 94 +3 158 - 2 42 +3 159 - 3 77 +3 160 - 5 86 +3 161 - 5 18 +3 162 - 7 1 +3 163 - 82 31 +3 164 - 84 12 +3 165 - 91 90 +3 166 - 91 68 +3 167 - 91 69 +3 168 - 92 33 +3 169 - 93 49 +3 170 - 95 51 +3 171 - 95 19 +3 172 - 0 44 +3 173 - 97 31 +3 174 - 99 11 +3 175 - 4 35 +3 176 - 80 10 +3 177 - 81 57 +3 178 - 83 77 +3 179 - 86 56 +3 180 - 86 64 +3 181 - 90 78 +3 182 - 94 57 +3 183 + 2 7 +3 184 + 3 98 +3 185 + 5 98 +3 186 + 6 95 +3 187 + 7 94 +3 188 + 82 8 +3 189 + 84 98 +3 190 + 91 96 +3 191 + 92 82 +3 192 + 93 11 +3 193 + 95 51 +3 194 + 96 98 +3 194 - 98 2 +3 195 + 98 93 +3 195 - 88 81 +3 196 + 88 6 +3 196 - 83 80 +3 197 + 83 85 +3 198 + 0 93 +3 199 + 85 44 +3 199 - 86 79 +3 200 + 86 87 +3 201 + 1 17 +3 202 + 79 17 +3 203 + 4 10 +3 204 + 81 85 +3 205 + 90 86 +3 206 + 87 96 +3 207 + 97 89 +3 208 + 89 4 +3 209 + 80 4 +3 210 + 99 85 +4 211 + 2 96 +4 211 - 3 98 +4 212 + 3 82 +4 212 - 6 95 +4 213 + 6 12 +4 213 - 7 94 +4 213 - 82 95 +4 213 - 82 8 +4 213 - 84 98 +4 214 + 84 49 +4 214 - 92 5 +4 215 + 92 84 +4 215 - 96 93 +4 215 - 96 91 +4 215 - 96 87 +4 216 + 91 5 +4 217 + 98 91 +4 218 + 95 36 +4 218 - 93 11 +5 219 - 96 98 +5 220 - 3 5 +5 221 - 6 98 +5 222 - 6 5 +5 223 - 6 88 +5 224 - 6 12 +5 225 - 7 5 +5 226 - 84 49 +5 227 - 93 0 +5 228 - 95 51 +5 229 - 95 36 +5 230 + 3 92 +5 231 + 6 19 +5 232 + 7 32 +5 233 + 92 66 +5 233 - 5 98 +5 233 - 5 91 +5 234 + 5 98 +5 235 + 95 5 +6 236 + 88 86 +6 237 + 83 97 +6 238 + 0 89 +6 239 + 94 28 +6 240 + 86 30 +6 241 + 81 64 +6 242 + 87 59 +6 243 + 97 99 +6 243 - 99 85 +6 244 + 99 15 +6 245 + 85 92 +6 246 + 80 1 +6 247 + 79 37 +6 248 + 1 75 +6 249 + 90 80 +7 250 - 97 1 +7 251 - 99 4 +7 252 - 99 79 +7 253 - 99 15 +7 254 - 81 80 +7 255 - 81 1 +7 256 - 81 85 +7 257 - 81 64 +7 258 - 83 85 +7 259 - 86 85 +7 260 - 86 4 +7 261 - 86 90 +7 262 - 86 30 +7 263 - 87 59 +7 264 - 89 4 +7 265 - 94 4 +7 266 - 94 85 +7 267 - 94 28 +7 268 + 4 79 +7 268 - 85 92 +7 269 + 85 80 +7 270 + 4 85 +7 271 + 80 9 +7 272 + 79 18 +7 272 - 1 75 +7 273 + 1 84 +7 273 - 88 86 +7 274 + 88 11 +7 275 + 83 0 +7 276 + 0 23 +7 277 + 94 8 +7 278 + 86 18 +7 279 + 81 88 +7 280 + 87 97 +7 281 + 89 86 +8 282 - 1 17 +8 283 - 1 84 +8 284 - 4 10 +8 285 - 79 17 +8 286 - 79 37 +8 287 - 79 18 +8 288 - 80 9 +8 289 - 85 44 +8 290 + 85 90 +8 290 - 4 79 +8 291 + 79 80 +8 292 + 1 90 +8 293 + 90 44 +8 293 - 88 11 +8 293 - 88 81 +8 294 + 88 29 +8 295 + 0 81 +8 295 - 94 89 +8 296 + 86 97 +8 297 + 81 83 +8 298 + 87 32 +8 299 + 89 99 +9 300 + 24 7 +9 301 + 25 90 +9 302 + 26 92 +9 303 + 27 71 +9 304 + 28 32 +9 305 + 29 25 +9 306 + 30 3 +9 307 + 31 96 +9 308 + 33 31 +9 309 + 2 30 +9 310 + 3 79 +9 311 + 6 62 +9 312 + 7 27 +9 313 + 82 32 +9 314 + 84 20 +9 315 + 92 6 +9 316 + 96 12 +10 317 - 32 16 +10 318 - 32 22 +10 319 - 32 87 +10 320 - 3 79 +10 321 - 96 12 +10 322 - 6 19 +10 323 - 6 62 +10 324 - 92 66 +10 325 - 84 20 +10 326 - 25 60 +10 327 - 25 90 +10 328 - 27 44 +10 329 - 27 46 +10 330 - 27 71 +10 331 - 29 12 +10 332 - 29 88 +10 333 - 30 71 +10 334 + 24 88 +10 335 + 25 84 +10 336 + 26 15 +10 337 + 27 6 +10 338 + 28 17 +10 339 + 29 1 +10 340 + 30 29 +10 341 + 31 94 +10 342 + 32 29 +10 343 + 33 28 +10 344 + 3 6 +10 345 + 6 29 +10 346 + 82 25 +10 347 + 92 21 +10 348 + 96 45 +11 349 + 53 66 +11 350 + 66 69 +11 351 + 75 78 +11 352 + 76 53 +11 353 + 78 53 +11 354 + 59 48 +11 355 + 46 72 +11 356 + 52 46 +11 357 + 56 50 +11 358 + 64 4 +11 359 + 63 90 +11 360 + 68 2 +11 361 + 58 74 +11 362 + 74 29 +11 363 + 51 4 +11 364 + 60 70 +11 365 + 57 45 +11 366 + 48 57 +11 367 + 61 62 +11 368 + 50 22 +11 369 + 55 64 +11 370 + 73 58 +11 371 + 67 71 +11 372 + 65 72 +11 373 + 47 54 +11 374 + 54 43 +11 375 + 62 59 +11 376 + 71 73 +11 377 + 70 73 +11 378 + 49 56 +11 379 + 77 56 +12 380 - 66 60 +12 381 - 69 47 +12 382 - 69 49 +12 383 - 75 67 +12 384 - 75 77 +12 385 - 76 65 +12 386 - 76 37 +12 387 - 78 62 +12 388 - 78 48 +12 389 - 53 48 +12 390 - 53 60 +12 391 - 53 68 +12 392 + 70 51 +12 392 - 59 62 +12 393 + 59 60 +12 393 - 46 52 +12 394 + 46 44 +12 395 + 52 98 +12 396 + 56 9 +12 396 - 64 4 +12 397 + 64 74 +12 397 - 63 90 +12 398 + 63 43 +12 399 + 68 47 +12 400 + 58 60 +12 400 - 74 29 +12 401 + 74 48 +12 401 - 51 4 +12 402 + 60 54 +12 403 + 57 17 +12 404 + 48 51 +12 405 + 61 49 +12 406 + 50 70 +12 407 + 55 74 +12 407 - 73 70 +12 408 + 73 63 +12 409 + 67 58 +12 409 - 65 72 +12 410 + 65 58 +12 411 + 47 67 +12 412 + 54 89 +12 413 + 62 56 +12 414 + 72 4 +12 415 + 71 72 +12 416 + 49 70 +12 417 + 77 46 +12 418 + 53 9 +12 419 + 69 78 +12 420 + 75 7 +12 421 + 76 50 +13 422 - 46 44 +13 423 - 50 20 +13 424 - 50 22 +13 425 - 50 76 +13 426 - 51 13 +13 427 - 52 14 +13 428 - 52 98 +13 429 - 54 43 +13 430 - 54 89 +13 431 - 55 42 +13 432 - 56 20 +13 433 - 56 9 +13 434 - 57 45 +13 435 - 57 17 +13 436 - 63 43 +13 437 - 68 2 +13 438 - 71 23 +13 439 - 72 4 +13 440 - 77 36 +13 441 + 59 86 +13 441 - 46 77 +13 442 + 46 22 +13 443 + 52 85 +13 444 + 56 47 +13 445 + 64 51 +13 446 + 63 51 +13 447 + 68 69 +13 447 - 58 73 +13 448 + 58 61 +13 448 - 74 55 +13 449 + 74 67 +13 450 + 51 16 +13 451 + 60 93 +13 452 + 57 68 +13 453 + 48 17 +13 454 + 50 54 +13 455 + 55 59 +13 455 - 73 71 +13 456 + 67 55 +13 457 + 65 61 +13 458 + 47 19 +13 459 + 54 91 +13 460 + 62 52 +13 461 + 72 60 +13 462 + 71 65 +13 463 + 70 59 +13 464 + 49 35 +13 465 + 77 62 +13 465 - 53 9 +13 466 + 53 21 +13 466 - 75 7 +13 467 + 75 53 +13 468 + 76 69 +13 469 + 78 66 +14 470 + 8 10 +14 471 + 9 63 +14 472 + 10 5 +14 473 + 12 93 +14 474 + 13 8 +14 475 + 14 13 +14 476 + 5 59 +14 477 + 91 12 +14 478 + 95 13 +15 479 - 5 59 +15 480 - 8 94 +15 481 - 9 63 +15 482 - 11 34 +15 483 - 15 23 +15 484 - 15 39 +15 485 - 15 26 +15 486 - 91 54 +15 487 - 93 60 +15 488 + 9 93 +15 489 + 11 5 +15 490 + 12 98 +15 491 + 14 94 +15 492 + 15 91 +15 493 + 5 91 +15 494 + 98 95 +15 495 + 95 14 +16 496 + 85 16 +16 497 + 4 28 +16 498 + 79 53 +16 499 + 1 86 +16 500 + 90 34 +16 500 - 53 21 +16 501 + 69 22 +16 502 + 75 4 +16 503 + 76 78 +17 504 - 1 29 +17 505 - 1 86 +17 506 - 4 28 +17 507 - 69 68 +17 508 - 69 22 +17 509 - 85 52 +17 510 - 85 16 +17 511 - 90 44 +17 512 - 90 34 +17 513 + 85 9 +17 514 + 4 32 +17 515 + 80 53 +17 516 + 79 3 +17 517 + 1 4 +17 518 + 90 78 +17 519 + 66 12 +17 520 + 69 87 +17 521 + 75 85 +18 522 + 16 49 +18 523 + 17 42 +18 524 + 18 15 +18 525 + 19 18 +18 526 + 23 6 +18 527 + 20 66 +19 528 + 16 23 +19 529 + 17 19 +19 530 + 19 23 +20 531 - 16 51 +20 532 - 16 49 +20 533 - 17 28 +20 534 - 17 48 +20 535 - 17 42 +20 536 - 18 86 +20 537 - 18 15 +20 538 - 19 47 +20 539 - 23 21 +20 540 - 23 0 +20 541 - 23 6 +20 542 + 20 22 +20 543 + 17 39 +20 544 + 19 30 +20 545 + 23 60 +20 545 - 20 66 +21 546 - 17 39 +21 547 - 19 30 +21 548 - 23 60 +21 549 - 21 92 +21 550 - 22 38 +21 551 - 22 46 +21 551 - 17 19 +21 552 + 17 41 +21 553 + 23 69 +21 553 - 22 20 +21 554 + 22 20 +21 555 + 21 14 +22 556 - 21 14 +22 557 + 16 45 +22 558 + 17 39 +22 559 + 18 17 +22 560 + 19 31 +22 561 + 23 18 +22 562 + 22 21 +23 563 - 16 45 +23 564 - 17 41 +23 565 - 17 39 +23 566 - 19 31 +23 567 - 23 69 +23 568 + 16 68 +23 568 - 18 23 +23 569 + 23 62 +24 570 + 24 13 +24 571 + 25 76 +24 572 + 27 33 +24 573 + 30 27 +24 574 + 31 82 +24 575 + 33 7 +24 576 + 3 31 +24 577 + 6 30 +24 578 + 82 6 +24 579 + 84 27 +24 580 + 92 8 +24 581 + 96 92 +24 582 + 2 29 +24 583 + 26 66 +24 584 + 28 2 +25 585 - 96 2 +25 586 - 96 45 +25 587 - 33 26 +25 588 - 33 28 +25 589 - 3 79 +25 590 - 6 29 +25 591 - 7 2 +25 592 - 7 32 +25 593 - 82 32 +25 594 - 24 28 +25 595 - 24 88 +25 596 - 24 13 +25 597 - 25 26 +25 598 - 25 32 +25 599 - 25 29 +25 600 - 25 76 +25 601 - 27 32 +25 602 - 27 28 +25 603 - 92 26 +25 604 - 92 8 +25 605 - 30 2 +25 606 - 30 29 +25 607 - 31 32 +25 608 - 31 94 +25 609 + 28 26 +25 610 + 32 11 +25 611 + 2 26 +25 611 - 26 66 +25 612 + 26 94 +25 613 + 29 14 +25 614 + 28 29 +25 615 + 25 71 +25 615 - 27 33 +25 616 + 27 33 +25 617 + 30 19 +25 618 + 33 30 +25 619 + 6 7 +25 620 + 7 9 +25 621 + 84 24 +25 621 - 92 96 +25 622 + 92 30 +25 623 + 96 2 +26 624 - 32 4 +26 625 - 32 11 +26 626 - 2 96 +26 627 - 26 94 +26 628 - 29 14 +26 629 + 24 19 +26 630 + 25 6 +26 630 - 27 33 +26 631 + 27 4 +26 631 - 30 19 +26 632 + 30 66 +26 633 + 31 27 +26 634 + 33 34 +26 635 + 3 44 +26 635 - 6 7 +26 636 + 6 84 +26 637 + 82 33 +26 638 + 84 9 +26 639 + 92 33 +26 640 + 96 25 +26 641 + 32 23 +27 642 + 24 50 +27 642 - 25 71 +27 642 - 25 6 +27 643 + 25 7 +27 643 - 27 4 +27 644 + 30 7 +27 645 + 31 72 +27 646 + 33 96 +27 647 + 3 27 +27 647 - 6 84 +27 647 - 7 9 +27 648 + 7 18 +27 649 + 82 57 +27 649 - 84 9 +27 650 + 84 39 +27 651 + 92 25 +27 652 + 96 24 +27 653 + 17 83 +27 653 - 18 19 +27 654 + 18 68 +27 655 + 19 25 +27 655 - 23 32 +27 656 + 23 7 +28 657 + 24 92 +28 657 - 25 19 +28 658 + 25 24 +28 658 - 27 84 +28 658 - 30 66 +28 659 + 30 82 +28 659 - 31 72 +28 660 + 31 92 +28 660 - 33 34 +28 660 - 3 44 +28 661 + 3 81 +28 662 + 6 32 +28 663 + 7 97 +28 663 - 82 57 +28 664 + 82 19 +28 665 + 84 23 +28 666 + 92 18 +28 667 + 17 82 +29 668 + 18 22 +29 668 - 24 50 +29 669 + 24 4 +29 669 - 25 96 +29 670 + 25 31 +29 670 - 27 31 +29 670 - 27 3 +29 671 + 27 33 +29 671 - 30 7 +29 671 - 30 82 +29 672 + 30 96 +29 672 - 31 82 +29 673 + 31 84 +29 673 - 33 7 +29 674 + 3 25 +29 674 - 6 32 +29 675 + 6 71 +29 675 - 7 97 +29 676 + 7 96 +29 676 - 82 17 +29 677 + 84 3 +29 678 + 96 92 +29 679 + 17 19 +29 679 - 18 68 diff --git a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/ServiceClass.java b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/ServiceClass.java index af4b4431..8aea650a 100644 --- a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/ServiceClass.java +++ b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/ServiceClass.java @@ -1214,7 +1214,7 @@ public Response getClcs( @ApiResponse(code = 401, message = "Unauthorized") }) @Path("clcs/{clcId}/covers/{coverId}/graphs/{graphId}") @ApiOperation(tags = {"export"}, value = "Export CLC", notes = "Returns a clc in a specified format.") - public Response getCover(@PathParam("clcId") String clcIdStr, @PathParam("graphId") String graphIdStr, @PathParam("coverId") String coverIdStr, + public Response getClc(@PathParam("clcId") String clcIdStr, @PathParam("graphId") String graphIdStr, @PathParam("coverId") String coverIdStr, @DefaultValue("EVENT_LIST") @QueryParam("outputFormat") String clcOutputFormatStr) { try { String username = ((UserAgent) Context.getCurrent().getMainAgent()).getLoginName(); diff --git a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/adapters/coverInput/CommunityMemberListsCoverInputAdapter.java b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/adapters/coverInput/CommunityMemberListsCoverInputAdapter.java index d8085f1a..31303b1b 100644 --- a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/adapters/coverInput/CommunityMemberListsCoverInputAdapter.java +++ b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/adapters/coverInput/CommunityMemberListsCoverInputAdapter.java @@ -66,6 +66,13 @@ public Cover readCover(CustomGraph graph) throws AdapterException { * Reads edges */ while (line.size() >= 1) { + if(lineContainNonAlphaNumericChar(line)){ + line.remove(0); + for (int i = 0; i < line.size(); i++) { + line.set(i, removeNonAlphanumeric(line.get(i))); + } + } + System.out.println(line); int i=0; if(communityNamesDefined) { communityName = line.get(0); @@ -116,4 +123,27 @@ public Cover readCover(CustomGraph graph) throws AdapterException { return cover; } + /** + * Returns true if a line contains a character that is non-alphanumeric. Used for cleaning up rdyn ground-truth covers. + * @param line the line + * @return true if yes + */ + private boolean lineContainNonAlphaNumericChar(List line){ + for(String str: line){ + if(str.contains(",") || str.contains("[") || str.contains("]")){ + return true; + } + } + return false; + } + + /** + * Cleans up str from non-alphanumeric chars + * @param str the str containing node name + * @return cleaned up node name + */ + private String removeNonAlphanumeric(String str){ + str = str.replaceAll("[^a-zA-Z0-9]", ""); + return str; + } } diff --git a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/adapters/graphInput/TimestampedEdgeListInputAdapter.java b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/adapters/graphInput/TimestampedEdgeListInputAdapter.java index b57994e7..80654f13 100644 --- a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/adapters/graphInput/TimestampedEdgeListInputAdapter.java +++ b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/adapters/graphInput/TimestampedEdgeListInputAdapter.java @@ -125,6 +125,49 @@ public DynamicGraph readGraph() throws AdapterException { } line = Adapters.readLine(reader); } + } else if(line.size() == 5){ + // For RDyn datasets, because there is additionally an absolute ordering provided in the interactions + while (line.size() == 5) { + String sourceNodeName = line.get(3); + Node sourceNode; + if (!reverseNodeNames.containsKey(sourceNodeName)) { + sourceNode = graph.addNode(sourceNodeName); + reverseNodeNames.put(sourceNodeName, sourceNode); + graph.setNodeName(sourceNode, sourceNodeName); + } else { + sourceNode = reverseNodeNames.get(sourceNodeName); + } + String targetNodeName = line.get(4); + Node targetNode; + if (!reverseNodeNames.containsKey(targetNodeName)) { + targetNode = graph.addNode(targetNodeName); + reverseNodeNames.put(targetNodeName, targetNode); + graph.setNodeName(targetNode, targetNodeName); + } else { + targetNode = reverseNodeNames.get(targetNodeName); + } + String edgeDate = line.get(0); + String edgeAction = line.get(2); + if (edgeAction.equals("+")) { + Edge edge = graph.addEdge(UUID.randomUUID().toString(), sourceNode, targetNode); + graph.addDynamicInteraction(edge, edgeDate, edgeAction); + }else if(edgeAction.equals("-")) { + try { + Edge edge = graph.removeEdge(sourceNode,targetNode); + graph.addDynamicInteraction(edge, edgeDate, edgeAction); + } catch (ElementNotFoundException e1) { + try { + Edge edge = graph.removeEdge(targetNode, sourceNode); + graph.addDynamicInteraction(edge, edgeDate, edgeAction); + } catch (ElementNotFoundException e2) { + System.out.println(e1 + " and/or " + e2); + } + } + }else { + throw new AdapterException("Invalid action"); + } + line = Adapters.readLine(reader); + } } if(line.size() > 0) { throw new AdapterException("Invalid input format"); diff --git a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/algorithms/OcdAlgorithmExecutor.java b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/algorithms/OcdAlgorithmExecutor.java index f6de540f..9f984ead 100644 --- a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/algorithms/OcdAlgorithmExecutor.java +++ b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/algorithms/OcdAlgorithmExecutor.java @@ -38,14 +38,30 @@ public class OcdAlgorithmExecutor { */ public Cover execute(CustomGraph graph, OcdAlgorithm algorithm, int componentNodeCountFilter) throws OcdAlgorithmException, InterruptedException, OcdMetricException { CustomGraph graphCopy = new CustomGraph(graph); + DynamicGraph dynamicGraphCopy = new DynamicGraph(); GraphProcessor processor = new GraphProcessor(); processor.makeCompatible(graphCopy, algorithm.compatibleGraphTypes()); + //Static graph compatibility mostly for evaluation purposes + boolean staticToDynamic = false; + if(algorithm.compatibleGraphTypes().contains(GraphType.DYNAMIC) && !(graph instanceof DynamicGraph)){ + staticToDynamic = true; + System.out.println("Dynamic Conversion"); + dynamicGraphCopy = processor.makeDynamic(graphCopy); + } + if(algorithm.getAlgorithmType().toString().equalsIgnoreCase(CoverCreationType.SIGNED_PROBABILISTIC_MIXTURE_ALGORITHM.toString()) || algorithm.getAlgorithmType().toString().equalsIgnoreCase(CoverCreationType.WORD_CLUSTERING_REF_ALGORITHM.toString()) || algorithm.getAlgorithmType().toString().equalsIgnoreCase(CoverCreationType.COST_FUNC_OPT_CLUSTERING_ALGORITHM.toString()) || algorithm.getAlgorithmType().toString().equalsIgnoreCase(CoverCreationType.LOCAL_SPECTRAL_CLUSTERING_ALGORITHM.toString()) || algorithm.getAlgorithmType().toString().equalsIgnoreCase(CoverCreationType.LOUVAIN_ALGORITHM.toString()) || algorithm.getAlgorithmType().toString().equalsIgnoreCase(CoverCreationType.ILCD_ALGORITHM.toString())){ ExecutionTime executionTime = new ExecutionTime(); //TODO: I think it should be detectOverlappingCommunities(graphCopy) - Tobias - Cover cover = algorithm.detectOverlappingCommunities(graph); + Cover cover; + executionTime.start(); + if(staticToDynamic){ + cover = algorithm.detectOverlappingCommunities(dynamicGraphCopy); + }else{ + cover = algorithm.detectOverlappingCommunities(graph); + } cover.setCreationMethod(new CoverCreationLog(algorithm.getAlgorithmType(), algorithm.getParameters(), algorithm.compatibleGraphTypes())); cover.getCreationMethod().setStatus(ExecutionStatus.COMPLETED); + executionTime.stop(); executionTime.setCoverExecutionTime(cover); return cover; }else{ diff --git a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/algorithms/iLCDAlgorithm.java b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/algorithms/iLCDAlgorithm.java index 14175a51..c404fa02 100644 --- a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/algorithms/iLCDAlgorithm.java +++ b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/algorithms/iLCDAlgorithm.java @@ -290,9 +290,14 @@ public Cover detectOverlappingCommunities(CustomGraph graph) throws OcdAlgorithm throw new OcdAlgorithmException("Graph is static"); } + System.out.println("graphCommunities: " + graphCommunities.size()); Matrix community_matrix = getCommunityMatrix((DynamicGraph) graph, graphCommunities); + System.out.println("matrix count: " + community_matrix.columns()); printCommunities(graphCommunities); Cover cover = new Cover(graph, community_matrix); + System.out.println("community count in cover: " + cover.communityCount()); + iLCDCommunityAgent reset = new iLCDCommunityAgent(); + reset.resetCounter(); return cover; } diff --git a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/algorithms/utils/iLCDCommunityAgent.java b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/algorithms/utils/iLCDCommunityAgent.java index d8cf499a..1d92283a 100644 --- a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/algorithms/utils/iLCDCommunityAgent.java +++ b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/algorithms/utils/iLCDCommunityAgent.java @@ -85,6 +85,10 @@ public List getNodeNamesAsList(){ return result; } + public void resetCounter(){ + communityIndexer = 0; + } + ///////////////////////////////////////////////////Methods////////////////////////////////////////////////////////// /** diff --git a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/graphs/GraphProcessor.java b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/graphs/GraphProcessor.java index e0bb9650..c0b3a897 100644 --- a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/graphs/GraphProcessor.java +++ b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/graphs/GraphProcessor.java @@ -3,7 +3,7 @@ import i5.las2peer.services.ocd.utils.Pair; - +import org.apache.commons.math3.random.RandomAdaptor; import org.apache.jena.atlas.iterator.Iter;//TODO: why this iterator? i think iterator is already in java.util import org.la4j.matrix.Matrix; import org.la4j.matrix.sparse.CCSMatrix; @@ -13,6 +13,7 @@ import org.graphstream.graph.Node; import java.util.*; +import java.util.stream.Collectors; /** * Pre-processes graphs to facilitate community detection. @@ -80,7 +81,7 @@ public void determineGraphTypes(CustomGraph graph) { * The graph to be transformed. */ public void makeUndirected(CustomGraph graph) { - + System.out.println("makeUndirected"); // copy of the input graph to be used for iteration CustomGraph graphCopy = new CustomGraph(graph); @@ -391,6 +392,27 @@ public void makeDirected(CustomGraph graph) { graph.addType(GraphType.DIRECTED); } + public DynamicGraph makeDynamic(CustomGraph graph){ + DynamicGraph dynamicCopy = new DynamicGraph(graph); + ArrayList edgeList = new ArrayList<>(graph.edges().collect(Collectors.toList())); + + Comparator cmp = Comparator.comparing((Edge edge) -> edge.getNode0().getIndex()) + .thenComparing((Edge edge) -> edge.getNode1().getIndex()); + Collections.sort(edgeList,cmp); + + //Maybe random shuffle for quality of covers since edges are sorted + Collections.shuffle(edgeList, new Random(19624)); + int date = 0; + for(Edge edge: edgeList){ + dynamicCopy.addDynamicInteraction(edge, String.valueOf(date), "+"); + date++; + } + for(DynamicInteraction di: dynamicCopy.getDynamicInteractions()){ + System.out.println(di.getSource().getName() + " - " + di.getTarget().getName()); + } + dynamicCopy.addType(GraphType.DYNAMIC); + return dynamicCopy; + } /** * Creates a graph, which is exactly a copy of the input graph * diff --git a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/CommunityLifeCycle.java b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/CommunityLifeCycle.java index ce912756..dc1a1cad 100644 --- a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/CommunityLifeCycle.java +++ b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/CommunityLifeCycle.java @@ -42,7 +42,7 @@ public class CommunityLifeCycle { /** * The graph the community life cycle is based on */ - private DynamicGraph graph = new DynamicGraph(); + private CustomGraph graph = new CustomGraph(); /** * The cover the community life cycle is based on */ @@ -63,7 +63,7 @@ public class CommunityLifeCycle { public CommunityLifeCycle() { } - public CommunityLifeCycle(Cover c, DynamicGraph g){ + public CommunityLifeCycle(Cover c, CustomGraph g){ this.graph = g; this.cover = c; } @@ -86,7 +86,7 @@ public void setCreationMethod(CoverCreationLog creationMethod) { } - public DynamicGraph getGraph() { + public CustomGraph getGraph() { return graph; } @@ -102,7 +102,7 @@ public void setName(String name) { this.name = name; } - public void setGraph(DynamicGraph graph) { + public void setGraph(CustomGraph graph) { this.graph = graph; } @@ -265,7 +265,7 @@ public void persist(ArangoDatabase db, String transId){ collection.updateDocument(this.key, bd, updateOptions); } - public static CommunityLifeCycle load(String key, Cover c, DynamicGraph g, ArangoDatabase db, String transId){ + public static CommunityLifeCycle load(String key, Cover c, CustomGraph g, ArangoDatabase db, String transId){ CommunityLifeCycle clc = null; ArangoCollection collection = db.collection(collectionName); DocumentReadOptions readOpt = new DocumentReadOptions().streamTransactionId(transId); diff --git a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/Database.java b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/Database.java index ab67a3b6..4352c160 100644 --- a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/Database.java +++ b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/Database.java @@ -1009,6 +1009,12 @@ public void deleteCover(String username, String graphKey, String coverKey, Threa /////////////////////////////////////////////// COMMUNTIY LIFE CYCLE ////////////////////////////////////////////////////////// + + /** + * Stores a community life cycle in the database. + * @param clc the clc to store + * @return the key of the persisted clc + */ public String storeCLC(CommunityLifeCycle clc){ String transId = this.getTransactionId(CommunityLifeCycle.class, true); try{ @@ -1021,7 +1027,14 @@ public String storeCLC(CommunityLifeCycle clc){ return clc.getKey(); } - public CommunityLifeCycle getCLC(String key, Cover c, DynamicGraph g){ + /** + * Load a community life cycle from the database. + * @param key the key of the clc to load + * @param c the cover which is connected to the clc + * @param g the graph the clc is based on + * @return the clc object that was loaded + */ + public CommunityLifeCycle getCLC(String key, Cover c, CustomGraph g){ String transId = this.getTransactionId(CommunityLifeCycle.class, false); CommunityLifeCycle clc; try { @@ -1033,19 +1046,34 @@ public CommunityLifeCycle getCLC(String key, Cover c, DynamicGraph g){ return clc; } + /** + * Loads a community life cycle from the database based on the keys. Uses getClc() after loading the + * DynamicGraph and Cover. + * @param username the username the graph is tagged with + * @param clcKey the key of the clc in the db + * @param graphKey the key of the graph in the db + * @param coverKey the key of the cover in the db + * @return the clc object that was loaded + */ public CommunityLifeCycle getCLC(String username, String clcKey, String graphKey, String coverKey){ - DynamicGraph graph = (DynamicGraph) getGraph(graphKey); + CustomGraph graph = getGraph(graphKey); + Cover cover = getCover(coverKey, graph); CommunityLifeCycle clc = null; if(!(graph == null) && !(cover==null)){ clc = getCLC(clcKey, cover, graph); } - if(cover == null){ + if(clc == null){ logger.log(Level.WARNING, "user: " + username + ", " + "CLC does not exist: cover id " + clcKey + ", graph id " + graphKey + ", cover id " + coverKey); } return clc; } + /** + * Deletes a community life cycle from the database. + * @param key the key of the clc to delete + * @param transId the transaction id + */ private void deleteClc(String key, String transId) { ArangoCollection clcCollection = db.collection(CommunityLifeCycle.collectionName); @@ -1065,6 +1093,10 @@ private void deleteClc(String key, String transId) { clcCollection.deleteDocument(key, null, deleteOpt); //delete Cover } + /** + * Deletes a community life cycle from the database. Uses deleteClc() with the transaction id. + * @param key the key of the clc to delete + */ public void deleteClc(String key) { String transId = this.getTransactionId(CommunityLifeCycle.class, true); try { diff --git a/rest_ocd_services/src/test/java/i5/las2peer/services/ocd/adapters/coverInput/CommunityMemberListsInputAdapterTest.java b/rest_ocd_services/src/test/java/i5/las2peer/services/ocd/adapters/coverInput/CommunityMemberListsInputAdapterTest.java index 3a081f76..a2a9e08d 100644 --- a/rest_ocd_services/src/test/java/i5/las2peer/services/ocd/adapters/coverInput/CommunityMemberListsInputAdapterTest.java +++ b/rest_ocd_services/src/test/java/i5/las2peer/services/ocd/adapters/coverInput/CommunityMemberListsInputAdapterTest.java @@ -6,6 +6,7 @@ import i5.las2peer.services.ocd.adapters.coverInput.CoverInputAdapter; import i5.las2peer.services.ocd.graphs.Cover; import i5.las2peer.services.ocd.graphs.CustomGraph; +import i5.las2peer.services.ocd.graphs.DynamicGraph; import i5.las2peer.services.ocd.testsUtils.OcdTestConstants; import i5.las2peer.services.ocd.testsUtils.OcdTestGraphFactory; @@ -39,4 +40,13 @@ public void testOnFacebook() throws AdapterException, FileNotFoundException { assertEquals(193, cover.communityCount()); } + @Test + public void testOnRDynGroundTruth() throws AdapterException, FileNotFoundException { + DynamicGraph graph = OcdTestGraphFactory.getRDynGtGraph(); + Cover cover; + CoverInputAdapter adapter = new CommunityMemberListsCoverInputAdapter(new FileReader(OcdTestConstants.rdynGtCommunityMemberListxInputPath)); + cover = adapter.readCover(graph); + System.out.println(cover.communityCount()); + System.out.println(cover); + } } diff --git a/rest_ocd_services/src/test/java/i5/las2peer/services/ocd/testsUtils/OcdTestConstants.java b/rest_ocd_services/src/test/java/i5/las2peer/services/ocd/testsUtils/OcdTestConstants.java index 281bbf8d..5a773a7e 100644 --- a/rest_ocd_services/src/test/java/i5/las2peer/services/ocd/testsUtils/OcdTestConstants.java +++ b/rest_ocd_services/src/test/java/i5/las2peer/services/ocd/testsUtils/OcdTestConstants.java @@ -50,6 +50,8 @@ public class OcdTestConstants { public static final String timestampedKarateClubPath = inputFolderPath + "KarateClubTimestampedAction.txt"; public static final String rdynTestGraphPath = inputFolderPath + "rdynConversion.txt"; + + public static final String rdynGtGraphPath = inputFolderPath + "rdynGtGraph.txt"; /* * Cover input filenames @@ -73,7 +75,8 @@ public class OcdTestConstants { + "signedLfrBlurredGroundTruthLabeledMembershipMatrix.txt"; public static final String sloveneParliamentaryPartyCommunityMemberMatrixInputPath = inputFolderPath + "sloveneParliamentaryPartyGroundTruthMembershipMatrix.txt"; - + + public static final String rdynGtCommunityMemberListxInputPath = inputFolderPath + "rdynGtCommunityMemberList.txt"; /* * Cover output filenames */ @@ -141,6 +144,8 @@ public class OcdTestConstants { public static final String timestampedKarateName = "Timestamped Karate"; public static final String rdynTestGraph = "RDyn Test Graph"; + + public static final String rdynGtGraph = "RDyn GT Graph"; /* * others diff --git a/rest_ocd_services/src/test/java/i5/las2peer/services/ocd/testsUtils/OcdTestGraphFactory.java b/rest_ocd_services/src/test/java/i5/las2peer/services/ocd/testsUtils/OcdTestGraphFactory.java index a9e4e959..74968c01 100644 --- a/rest_ocd_services/src/test/java/i5/las2peer/services/ocd/testsUtils/OcdTestGraphFactory.java +++ b/rest_ocd_services/src/test/java/i5/las2peer/services/ocd/testsUtils/OcdTestGraphFactory.java @@ -915,4 +915,17 @@ public static DynamicGraph getRdynTestGraph() throws AdapterException, FileNotFo graph.setCreationMethod(log); return graph; } + + public static DynamicGraph getRDynGtGraph() throws AdapterException, FileNotFoundException { + GraphInputAdapter adapter = new TimestampedEdgeListInputAdapter(new FileReader(OcdTestConstants.rdynGtGraphPath)); + DynamicGraph graph = (DynamicGraph) adapter.readGraph(); + graph.setName(OcdTestConstants.rdynGtGraph); + GraphProcessor processor = new GraphProcessor(); + graph.addType(GraphType.DYNAMIC); + processor.makeCompatible(graph, new HashSet()); + GraphCreationLog log = new GraphCreationLog(GraphCreationType.UNDEFINED, new HashMap()); + log.setStatus(ExecutionStatus.COMPLETED); + graph.setCreationMethod(log); + return graph; + } } diff --git a/time_seed.dat b/time_seed.dat index a3d0db9a..d6c25be9 100644 --- a/time_seed.dat +++ b/time_seed.dat @@ -1 +1 @@ -21112234 \ No newline at end of file +21112428 \ No newline at end of file