We consider a pair \(({\mathfrak {A}},{{\mathcal {B}}})\) where \({\mathfrak {A}}\) is an algebra over a base field \({\mathbb F}\) , and \({{\mathcal {B}}}=\{e_{i}\}_{i \in I}\) a basis of \({\mathfrak {A}}\) satisfying the following property: for any \(i,j \in I\) we have \(e_ie_j \in {\mathbb {F}} e_k\) for some \(k \in I\) . We show that \({\mathfrak {A}}\) decomposes as \({\mathfrak {A}}={\mathfrak {s}} \oplus {\mathfrak {d}}\) where \({\mathfrak {s}}\) is a semisimple ideal of \({\mathfrak {A}}\) , (a direct sum of simple ideals), and \({\mathfrak {d}}\) is the direct sum of non-simple indecomposable ideals of \({\mathfrak {A}}\) . Moreover, this decomposition is unique. We show that the ideals \({\mathfrak {s}}\) and \({\mathfrak {d}}\) are characterized by a new linear property. An interpretation of this result in terms of graph theory is also provided.