Functorial Approach to Graph and Hypergraph Theory