graph and matrix implementation, first version of online algorithms