Here is an interesting problem that I encountered in a programming competition:
Problem statement: Given the dimensions of n
matrices,
Create a compatibility matrix (let's call it CM) such as CM[x,y] = 1 if the matrix x can be multuplied by y, 0 if not. if Determinant(CM) <> 0 there is an order.
It's just an intuition, I apologize if I'm wrong (unfortunately I couldn't find a solid proof).
Create a node for each dimension length. That is, if there is a matrix of dimension (m,n), then m and n will be vertices in the graph.
For every matrix of size (m,n) connect nodes m and n with a directed edge (there can be multiple edges between two nodes).
Now finding a eularian trail would give the multiplication order.
See http://en.wikipedia.org/wiki/Euler_path for finding Eularian trails. Complexity is pretty close to linear ( O(nlog^3n loglogn) where n is the number of edges = number of matrices) .