# MultiAspect Graphs: Algebraic Representation and Algorithms
## 3 Algebraic Representation
### Ordering of Composite Vertices and Aspects  
In general, the sequence in which the composite vertices and aspects are organized on a MAG is not relevant. That is, changing the sequence in which the aspects or their elements are presented does not affect the result of any algorithm or analysis performed on a MAG, since the MAG obtained by such changes is isomorphic to the original one. The definition of the MAG isomorphism adopted in this work can be found in Section 2.4. However, to show the MAG's algebraic representation in a consistent way, it is necessary to link the MAG's composite vertices to rows and columns of matrices, which is achieved by the bijective function \(D\), defined in this section at Equation (15). We now show the preliminary steps necessary for the definition of function \(D\), as implemented in this work. The aspect sequence is adopted as the same in which the aspects are placed on the MAG's companion tuple. For the ordering of composite vertices, we define the numerical representation of each composite vertex from its tuple. To obtain the composite vertex numerical representation, we first translate the composite vertex into a numerical tuple. This is done by applying a family of indices, one for each aspect on the composite vertex, where for every aspect \(i\) the corresponding index ranges from 0 to \(\tau_{i}-1\), where \(\tau_{i}\) is the number of elements on the \(i\)-th aspect of the MAG. Since this is a simple index substitution, we do not use a distinct notation for the composite vertex on its numerical tuple form. We, however, reserve the notation \(\mathbf{u}[i]\) to express the \(i\)-th element of the composite vertex on its numerical form. To calculate the numerical representation of a composite vertex, we define the weight of each position on the composite vertex tuple of a MAG \(H\) with \(p\) aspects as  
\[W(i,\tau)=\left\{ \begin{array}{ll}1&\text{if }i=1,\\ \prod_{j=1}^{i-1}\tau_{j}&\text{otherwise},\end{array} \right. \tag{14}\]  
where \(i\) is the position in the tuple varying from 1 to \(p\), \(\tau\) is the MAG's companion tuple, and \(\tau_{j}\) is the \(j\)-th element of the MAG's companion tuple. Note that \(|\tau|=p\) meaning that the length of the companion tuple is the order of the MAG, i.e., the number of its aspects. Finally, we define the composite vertex numerical representation as  
\[D(\mathbf{u},\tau)=1+\sum_{i=1}^{|\tau|}W(i,\tau)\times\mathbf{u}[i], \tag{15}\]  
where \(|\tau|=p\) is the MAG's order, and \(\mathbf{v}[i]\) is the \(i\)-th component of the composite vertex. Figure 3 shows the MAG \(T\) with its composite vertices, and their numerical representations ranging from (1) to (18). To illustrate how the numerical representations are obtained, we show examples based on the MAG \(T\). For this representation, we adopt aspect indices such that for aspect 1 we have \(Idx(1)=0,Idx(2)=1\) and \(Idx(3)=2\). For aspect 2, we have \(Idx(Bus)=0\) and \(Idx(Subway)=1\), while for aspect 3, \(Idx(t_{1})=0,Idx(t_{2})=1\) and \(Idx(t_{3})=2\). Since the companion tuple of MAG \(T\) is \(\tau(T)=(3,2,3)=\tau\), the weights are \(W(1,\tau)=1\), \(W(2,\tau)=\tau_{1}=3\) and \(W(3,\tau)=\tau_{1}\times\tau_{2}=6\). Therefore, the composite vertex \(\mathbf{v}=(1,Bus,t_{1})\) has numerical representation \(D(\mathbf{v},\tau)=1+1\times 0+3\times 0+6\times 0=1\), while \(D((2,Subway,t_{2}),\tau)=1+1\times 1+3\times 1+6\times 1=11\) and \(D((2,Bus,t_{3}),\tau)=1+1\times 1+3\times 0+6\times 2=14\). Algorithm 3 determines the numerical representation of a composite vertex \(v\) represented by its numerical tuple. The presented implementation extends the concepts presented in Equations (14) and (15), so that this algorithm can also be used to determine the numerical representation of sub-determined composite vertices. To determine the numerical representation of a sub-determined vertex, function \(D\) shown in Algorithm 3 receives the full composite vertex tuple (not sub-determined) and the sub-determined companion tuple.