# MultiAspect Graphs: Algebraic Representation and Algorithms
## 4 MAG Algorithms
### Universality of Matrix Algorithms
Note that by construction of \(\hat{H}\) we have that \(|E(\hat{H})|=|E(H)|\); \(|A(\hat{H})|=|A(H)|=p\); for \(1\leqslant i\leqslant p\), \(|A(\hat{H})[i]|=|A(H)[i]|\); \(|\mathbb{V}(\hat{H})|=|\mathbb{V}(H)|\); and \(\tau(\hat{H})=\tau(H)\). Since \(|\mathbb{V}(H)|=|\mathbb{V}(\hat{H})|\), we know that there is a bijective function from \(\mathbb{V}(\hat{H})\) to \(\mathbb{V}(H)\). Further, we also have the bijective function \(D\), which takes a composite vertex into a natural number, assigning a unique and distinct natural number to each element of \(\mathbb{V}(H)\) and \(\mathbb{V}(\hat{H})\). Moreover, since \(\tau(\hat{H})=\tau(H)\) and by construction of \(D\), we have that the range of \(D\) for \(\mathbb{V}(H)\) and \(\mathbb{V}(\hat{H})\) is the same, i.e., \(D(\mathbb{V}(H),\tau(H))=D(\mathbb{V}(\hat{H}),\tau(\hat{H}))\). From this, we conclude that, for every composite vertex \(\mathbf{u}\in\mathbb{V}(H)\), there is one unique composite vertex \(\hat{\mathbf{u}}\in\mathbb{V}(\hat{H})\) such that \(D(\mathbf{u},\tau(H))=D(\hat{\mathbf{u}},\tau(\hat{H}))\). We thus define the bijective function  
\[ \begin{split} f:\mathbb{V}(\hat{H})&\to\mathbb{V}(H )\\ \hat{\mathbf{u}}&\mapsto\mathbf{u},\text{ such that }D(\hat{\mathbf{u}},\tau(\hat{H}))=D(\mathbf{u},\tau(H)).\end{split}  \tag{35}\]  
As the function \(f\) is bijective, for every edge \(\hat{e}\in\hat{H}\), we have an edge \(e=(f(\pi_{o}(\hat{e}))\), \(f(\pi_{d}(\hat{e})))\in E(H)\), and also, for every edge \(e\in E(H)\), we have the corresponding edge \(\hat{e}=(f^{-1}(\pi_{o}(e)),f^{-1}(\pi_{d}(e)))\in E(\hat{H})\). This fulfils the conditions for isomorphism between \(\hat{H}\) and \(H\). Since \(\mathbb{H}\) is a quotient set under the MAG isomorphism relation and \(\hat{H}\) is isomorphic to \(H\), it follows that \(\hat{H}\) and \(H\) correspond to the same element in \(\mathbb{H}\), making the function Y bijective. Also, since each entry with value \(1\) in the adjacency matrix \(\mathbf{J}(H)\) corresponds to an edge in the MAG \(H\), it follows that Y\({}^{-1}\) also preserves the MAGs adjacency structure, establishing the isomorphism relation as desired. **Theorem 2**. : _Every function that can be obtained from a MAG to a given co-domain set can also be obtained from a matrix representation of the MAG._  
Proof. : Consider the diagram depicted in Figure 5. In this figure, \(\mathbb{H}\) is the set of all MAGs (up to isomorphism), \(\mathbb{J}\) is the set of pairs of adjacency matrices and companion tuples (up to permutation), \(F\) is an arbitrary function from \(\mathbb{H}\) to \(\mathbb{X}\), where \(\mathbb{X}\) is a codomain consistent with the definition of function \(F\), and \(I\) is the identity function in \(\mathbb{X}\). Since the function \(F\) is arbitrary, it can represent any function or algorithm, such as searches or centrality computations, which take MAGs to a result expected from this function. As both functions Y (Equation (33) in Theorem 1) and \(I\) represent isomorphisms, it follows that the depicted diagram commutes, so that for every function \(F:\mathbb{H}\to\mathbb{X}\) there is a function \(\hat{F}:\mathbb{J}\to\mathbb{X}\), which produces the same result. As a consequence of Theorem 2, it follows that, from the adjacency matrix and companion tuple of a MAG, one can obtain any possible outcome that can be obtained from a MAG or from any other representation equivalent to it, such as high order tensors, as those presented in recent related  
Figure 5: Commutative diagram. works [15; 35; 36]. Therefore, Theorem 2 actually shows that any possible MAG function (algorithm) can be obtained from a matrix-based representation of a MAG. This is an important theoretical result since it paves the way for adapting well-known graph algorithms for application in MAGs. In the next subsections, we show examples of basic algorithms and functions that can be obtained from the matrix-based representation of a MAG.