|
517 | 517 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
518 | 518 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
519 | 519 |
|
| 520 | +function BinaryMatrix = binarizeMatrix(Matrix) |
| 521 | + BinaryMatrix = double(Matrix|Matrix); |
| 522 | +endfunction |
| 523 | + |
| 524 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 525 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 526 | + |
520 | 527 | function MultiDegreeVector = GetMultiDegree(SupraAdjacencyMatrix,Layers,Nodes,Flags) |
521 | 528 | % References: |
522 | 529 | % M. De Domenico et al, Phys. Rev. X 3, 041022 (2013) |
523 | 530 |
|
524 | | - MultiInDegreeVector = GetMultiInDegree(SupraAdjacencyMatrix,Layers,Nodes,Flags); |
525 | | - MultiOutDegreeVector = GetMultiOutDegree(SupraAdjacencyMatrix,Layers,Nodes,Flags); |
| 531 | + MultiInDegreeVector = GetMultiInDegree(binarizeMatrix(SupraAdjacencyMatrix),Layers,Nodes,Flags); |
| 532 | + MultiOutDegreeVector = GetMultiOutDegree(binarizeMatrix(SupraAdjacencyMatrix),Layers,Nodes,Flags); |
526 | 533 |
|
527 | 534 | if ismember("U",Flags) |
528 | 535 | MultiDegreeVector = (MultiInDegreeVector + MultiOutDegreeVector)/2; |
|
541 | 548 |
|
542 | 549 | if ismember("U",Flags) |
543 | 550 | %we proceed by considering the interlayers separately |
544 | | - BlockTensor = SupraAdjacencyToBlockTensor(SupraAdjacencyMatrix,Layers,Nodes); |
| 551 | + BlockTensor = SupraAdjacencyToBlockTensor(binarizeMatrix(SupraAdjacencyMatrix),Layers,Nodes); |
545 | 552 |
|
546 | 553 | MultiOutDegreeVector = sparse(Nodes,1); |
547 | 554 |
|
|
559 | 566 | endfor |
560 | 567 | endfor |
561 | 568 | else |
562 | | - SupraDegree = SupraAdjacencyMatrix*ones(Nodes*Layers,1); |
| 569 | + SupraDegree = binarizeMatrix(SupraAdjacencyMatrix)*ones(Nodes*Layers,1); |
563 | 570 |
|
564 | 571 | MultiOutDegreeVector = sum(reshape(SupraDegree,Nodes,Layers),2); |
565 | 572 | endif |
|
575 | 582 |
|
576 | 583 | if ismember("U",Flags) |
577 | 584 | %using the following would consider multiple times the interlinks |
578 | | - %SupraDegree = (SupraAdjacencyMatrix*ones(Nodes*Layers,1) + (ones(1,Nodes*Layers)*SupraAdjacencyMatrix)')/2; |
| 585 | + %SupraDegree = (binarizeMatrix(SupraAdjacencyMatrix)*ones(Nodes*Layers,1) + (ones(1,Nodes*Layers)*binarizeMatrix(SupraAdjacencyMatrix))')/2; |
579 | 586 |
|
580 | 587 | %we proceed by considering the interlayers separately |
581 | | - BlockTensor = SupraAdjacencyToBlockTensor(SupraAdjacencyMatrix,Layers,Nodes); |
| 588 | + BlockTensor = SupraAdjacencyToBlockTensor(binarizeMatrix(SupraAdjacencyMatrix),Layers,Nodes); |
582 | 589 |
|
583 | 590 | MultiInDegreeVector = sparse(Nodes,1); |
584 | 591 |
|
|
596 | 603 | endfor |
597 | 604 | endfor |
598 | 605 | else |
599 | | - SupraDegree = (ones(1,Nodes*Layers)*SupraAdjacencyMatrix)'; |
| 606 | + SupraDegree = (ones(1,Nodes*Layers)*binarizeMatrix(SupraAdjacencyMatrix))'; |
600 | 607 |
|
601 | 608 | MultiInDegreeVector = sum(reshape(SupraDegree,Nodes,Layers),2); |
602 | 609 | endif |
|
609 | 616 | % References: |
610 | 617 | % M. De Domenico et al, Phys. Rev. X 3, 041022 (2013) |
611 | 618 |
|
612 | | - MultiInDegreeVector = GetMultiInDegreeSum(SupraAdjacencyMatrix,Layers,Nodes,Flags); |
613 | | - MultiOutDegreeVector = GetMultiOutDegreeSum(SupraAdjacencyMatrix,Layers,Nodes,Flags); |
| 619 | + MultiInDegreeVector = GetMultiInDegreeSum(binarizeMatrix(SupraAdjacencyMatrix),Layers,Nodes,Flags); |
| 620 | + MultiOutDegreeVector = GetMultiOutDegreeSum(binarizeMatrix(SupraAdjacencyMatrix),Layers,Nodes,Flags); |
614 | 621 |
|
615 | 622 | if ismember("U",Flags) |
616 | 623 | MultiDegreeVector = (MultiInDegreeVector + MultiOutDegreeVector)/2; |
|
628 | 635 | % M. De Domenico et al, Phys. Rev. X 3, 041022 (2013) |
629 | 636 |
|
630 | 637 |
|
631 | | - SupraDegree = SupraAdjacencyMatrix*ones(Nodes*Layers,1); |
| 638 | + SupraDegree = binarizeMatrix(SupraAdjacencyMatrix)*ones(Nodes*Layers,1); |
632 | 639 | MultiOutDegreeVector = sum(reshape(SupraDegree,Nodes,Layers),2); |
633 | 640 | endfunction |
634 | 641 |
|
|
641 | 648 | % M. De Domenico et al, Phys. Rev. X 3, 041022 (2013) |
642 | 649 |
|
643 | 650 |
|
644 | | - SupraDegree = (ones(1,Nodes*Layers)*SupraAdjacencyMatrix)'; |
| 651 | + SupraDegree = (ones(1,Nodes*Layers)*binarizeMatrix(SupraAdjacencyMatrix))'; |
645 | 652 | MultiInDegreeVector = sum(reshape(SupraDegree,Nodes,Layers),2); |
646 | 653 | endfunction |
647 | 654 |
|
| 655 | + |
| 656 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 657 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 658 | + |
| 659 | +function MultiStrengthVector = GetMultiStrength(SupraAdjacencyMatrix,Layers,Nodes,Flags) |
| 660 | + % References: |
| 661 | + % M. De Domenico et al, Phys. Rev. X 3, 041022 (2013) |
| 662 | + |
| 663 | + MultiInStrengthVector = GetMultiInStrength(SupraAdjacencyMatrix,Layers,Nodes,Flags); |
| 664 | + MultiOutStrengthVector = GetMultiOutStrength(SupraAdjacencyMatrix,Layers,Nodes,Flags); |
| 665 | + |
| 666 | + if ismember("U",Flags) |
| 667 | + MultiStrengthVector = (MultiInStrengthVector + MultiOutStrengthVector)/2; |
| 668 | + else |
| 669 | + MultiStrengthVector = MultiInStrengthVector + MultiOutStrengthVector; |
| 670 | + endif |
| 671 | +endfunction |
| 672 | + |
| 673 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 674 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 675 | + |
| 676 | +function MultiOutStrengthVector = GetMultiOutStrength(SupraAdjacencyMatrix,Layers,Nodes,Flags) |
| 677 | + % References: |
| 678 | + % M. De Domenico et al, Phys. Rev. X 3, 041022 (2013) |
| 679 | + |
| 680 | + |
| 681 | + if ismember("U",Flags) |
| 682 | + %we proceed by considering the interlayers separately |
| 683 | + BlockTensor = SupraAdjacencyToBlockTensor(SupraAdjacencyMatrix,Layers,Nodes); |
| 684 | + |
| 685 | + MultiOutStrengthVector = sparse(Nodes,1); |
| 686 | + |
| 687 | + %with the matrix U we reweight interlinks corresponding to same replicas |
| 688 | + U = ones(Nodes,Nodes); |
| 689 | + U(logical(speye(size(U)))) = 1/2; |
| 690 | + |
| 691 | + for i = 1:Layers |
| 692 | + for j = 1:Layers |
| 693 | + if i==j |
| 694 | + MultiOutStrengthVector += (BlockTensor{i,j}-diag(diag(BlockTensor{i,j})))*ones(Nodes,1) + diag(BlockTensor{i,j})*0.5; |
| 695 | + else |
| 696 | + MultiOutStrengthVector += (BlockTensor{i,j} .* U)*ones(Nodes,1); |
| 697 | + endif |
| 698 | + endfor |
| 699 | + endfor |
| 700 | + else |
| 701 | + SupraStrength = SupraAdjacencyMatrix*ones(Nodes*Layers,1); |
| 702 | + |
| 703 | + MultiOutStrengthVector = sum(reshape(SupraStrength,Nodes,Layers),2); |
| 704 | + endif |
| 705 | +endfunction |
| 706 | + |
| 707 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 708 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 709 | + |
| 710 | +function MultiInStrengthVector = GetMultiInStrength(SupraAdjacencyMatrix,Layers,Nodes,Flags) |
| 711 | + % References: |
| 712 | + % M. De Domenico et al, Phys. Rev. X 3, 041022 (2013) |
| 713 | + |
| 714 | + |
| 715 | + if ismember("U",Flags) |
| 716 | + %using the following would consider multiple times the interlinks |
| 717 | + %SupraStrength = (SupraAdjacencyMatrix*ones(Nodes*Layers,1) + (ones(1,Nodes*Layers)*SupraAdjacencyMatrix)')/2; |
| 718 | + |
| 719 | + %we proceed by considering the interlayers separately |
| 720 | + BlockTensor = SupraAdjacencyToBlockTensor(SupraAdjacencyMatrix,Layers,Nodes); |
| 721 | + |
| 722 | + MultiInStrengthVector = sparse(Nodes,1); |
| 723 | + |
| 724 | + %with the matrix U we reweight interlinks corresponding to same replicas |
| 725 | + U = ones(Nodes,Nodes); |
| 726 | + U(logical(speye(size(U)))) = 1/2; |
| 727 | + |
| 728 | + for i = 1:Layers |
| 729 | + for j = 1:Layers |
| 730 | + if i==j |
| 731 | + MultiInStrengthVector += (ones(1,Nodes)*(BlockTensor{i,j}-diag(diag(BlockTensor{i,j}))))' + diag(BlockTensor{i,j})*0.5; |
| 732 | + else |
| 733 | + MultiInStrengthVector += (ones(1,Nodes)*(BlockTensor{i,j} .* U))'; |
| 734 | + endif |
| 735 | + endfor |
| 736 | + endfor |
| 737 | + else |
| 738 | + SupraStrength = (ones(1,Nodes*Layers)*SupraAdjacencyMatrix)'; |
| 739 | + |
| 740 | + MultiInStrengthVector = sum(reshape(SupraStrength,Nodes,Layers),2); |
| 741 | + endif |
| 742 | +endfunction |
| 743 | + |
| 744 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 745 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 746 | + |
| 747 | +function MultiStrengthVector = GetMultiStrengthSum(SupraAdjacencyMatrix,Layers,Nodes,Flags) |
| 748 | + % References: |
| 749 | + % M. De Domenico et al, Phys. Rev. X 3, 041022 (2013) |
| 750 | + |
| 751 | + MultiInStrengthVector = GetMultiInStrengthSum(SupraAdjacencyMatrix,Layers,Nodes,Flags); |
| 752 | + MultiOutStrengthVector = GetMultiOutStrengthSum(SupraAdjacencyMatrix,Layers,Nodes,Flags); |
| 753 | + |
| 754 | + if ismember("U",Flags) |
| 755 | + MultiStrengthVector = (MultiInStrengthVector + MultiOutStrengthVector)/2; |
| 756 | + else |
| 757 | + MultiStrengthVector = MultiInStrengthVector + MultiOutStrengthVector; |
| 758 | + endif |
| 759 | +endfunction |
| 760 | + |
| 761 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 762 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 763 | + |
| 764 | +function MultiOutStrengthVector = GetMultiOutStrengthSum(SupraAdjacencyMatrix,Layers,Nodes,Flags) |
| 765 | + %this Strength include multiple times the interlinks |
| 766 | + % References: |
| 767 | + % M. De Domenico et al, Phys. Rev. X 3, 041022 (2013) |
| 768 | + |
| 769 | + |
| 770 | + SupraStrength = SupraAdjacencyMatrix*ones(Nodes*Layers,1); |
| 771 | + MultiOutStrengthVector = sum(reshape(SupraStrength,Nodes,Layers),2); |
| 772 | +endfunction |
| 773 | + |
| 774 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 775 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 776 | + |
| 777 | +function MultiInStrengthVector = GetMultiInStrengthSum(SupraAdjacencyMatrix,Layers,Nodes,Flags) |
| 778 | + %this Strength include multiple times the interlinks |
| 779 | + % References: |
| 780 | + % M. De Domenico et al, Phys. Rev. X 3, 041022 (2013) |
| 781 | + |
| 782 | + |
| 783 | + SupraStrength = (ones(1,Nodes*Layers)*SupraAdjacencyMatrix)'; |
| 784 | + MultiInStrengthVector = sum(reshape(SupraStrength,Nodes,Layers),2); |
| 785 | +endfunction |
| 786 | + |
| 787 | + |
| 788 | + |
| 789 | + |
648 | 790 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
649 | 791 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
650 | 792 |
|
|
0 commit comments