Graphs and patterns in mathematics and theoretical physics