I work with linear combinations of graphs, $$c_1 G_1 + c_2 G_2 + \dotsc,$$ and I want to represent them in my Mathematica code. I represent graphs as adjacency matrices, e.g.
{{0,1},{1,0}}
The next step is to write down linear combinations of these matrices. However, I want to implement formal linear combinations of the kind
lin = 5 * AdjMtx[{{0,1},{1,0}}] + 3 * AdjMtx[{{1,0},{0,1}}]
with an unevaluated "function" or type AdjMtx
. The reason I don't want to write
5 * {{0,1},{1,0}} + 3 * {{1,0},{0,1}}
is that Mathematica then treats the adjacency matrices as normal matrices which admit multiplication my scalars etc.
AdjMtx
should allow other functions to access the contents of adjacency matrices as usual. For example, a function should be able to search through a linear combination of adjacency matrices and read out their respective matrix elements.
I guess that moving through a linear combination, e.g. lin
from above, is just done using Part
. Then the question is how to do implement something like
AdjMtx[...][[3,4]]
lin
? $\endgroup$Plus
. Less clear is whetherTimes
should also be replaced or in other ways inhibited e.g. by using a head for the matrices that is notList
. $\endgroup$