Coloring graphs is one of important and frequently used topics in diverse sciences. In the majority of the articles, it is intended to find a proper bound for vertex coloring, edge coloring or total coloring in the graph. Although it is important to find a proper algorithm for graph coloring, it is hard and time-consuming too. In this paper, a new algorithm for vertex coloring, edge coloring and [r, s, t]- coloring is presented. Then, this algorithm is used to solve the applied problems of eight-queens and [r, s, t]- coloring. Here, there are numerical examples to study the efficiency of the method and to compare the results.