r""" Format an attributed graph :math:`(\mathbf{C}, \mathbf{F}, \mathbf{p})` with structure matrix :math:`(\mathbf{C} \in R^{n \times n}`, feature matrix :math:`(\mathbf{F} \in R^{n \times d}` and node relative importance :math:`(\mathbf{p} \in \Sigma_n`, into a partitioned attribute
(
C, p, part, rep_indices, F=None, M=None, alpha=1.0, nx=None
)
| 455 | |
| 456 | |
| 457 | def format_partitioned_graph( |
| 458 | C, p, part, rep_indices, F=None, M=None, alpha=1.0, nx=None |
| 459 | ): |
| 460 | r""" |
| 461 | Format an attributed graph :math:`(\mathbf{C}, \mathbf{F}, \mathbf{p})` |
| 462 | with structure matrix :math:`(\mathbf{C} \in R^{n \times n}`, feature matrix |
| 463 | :math:`(\mathbf{F} \in R^{n \times d}` and node relative importance |
| 464 | :math:`(\mathbf{p} \in \Sigma_n`, into a partitioned attributed graph |
| 465 | taking into account partitions and representants :math:`\mathcal{P} = \left{(\mathbf{P_{i}}, \mathbf{r_{i}})\right}_i`. |
| 466 | |
| 467 | Parameters |
| 468 | ---------- |
| 469 | C : array-like, shape (n, n) |
| 470 | Structure matrix. |
| 471 | p : array-like, shape (n,), |
| 472 | Node distribution. |
| 473 | part : array-like, shape (n,) |
| 474 | Array of partition assignment for each node. |
| 475 | rep_indices : list of array-like of ints, shape (npart,) |
| 476 | indices for representative node of each partition sorted according to |
| 477 | partition identifiers. |
| 478 | F : array-like, shape (n, d), optional. (Default is None) |
| 479 | Optional feature matrix aligned with the graph structure. |
| 480 | M : array-like, shape (n, n), optional. (Default is None) |
| 481 | Optional pairwise similarity matrix between features. |
| 482 | alpha: float, optional. Default is 1. |
| 483 | Trade-off parameter in :math:`]0, 1]` between structure and features. |
| 484 | If `alpha = 1` features are ignored. This trade-off is taken into account |
| 485 | into the outputted relations between nodes and representants. |
| 486 | nx : backend, optional |
| 487 | POT backend |
| 488 | |
| 489 | Returns |
| 490 | ------- |
| 491 | CR : array-like, shape (npart, npart) |
| 492 | Structure matrix between partition representants. |
| 493 | list_R : list of npart arrays, |
| 494 | List of relations between a representant and nodes in its partition, |
| 495 | for each partition. |
| 496 | list_p : list of npart arrays, |
| 497 | List of node distributions within each partition. |
| 498 | FR : array-like, shape (npart, d), if `F != None`. |
| 499 | Feature matrix of representants. |
| 500 | |
| 501 | References |
| 502 | ---------- |
| 503 | .. [68] Chowdhury, S., Miller, D., & Needham, T. (2021). |
| 504 | Quantized gromov-wasserstein. ECML PKDD 2021. Springer International Publishing. |
| 505 | |
| 506 | """ |
| 507 | if nx is None: |
| 508 | arr = [C, p, part] |
| 509 | if F is not None: |
| 510 | arr.append(F) |
| 511 | if M is not None: |
| 512 | arr.append(M) |
| 513 | |
| 514 | nx = get_backend(*arr) |
no test coverage detected