In this paper, we use the graphs as a tool to study nilpotent Lie algebras. It implies to set up a link between graph theory and Lie theory. To do this, it is already known that every nilpotent Lie algebra of maximal rank is associated with a generalized Cartan matrix A and it is isomorphic to a quotient of the positive part n+ of the KacMoody algebra g(A). Then, if A is affine, we can associate n+ with a directed graph (from now on, we use the term digraph) and we can also associate a subgraph of this digraph with every isomorphism class of nilpotent Lie algebras of maximal rank and of type A. Finally, we show an algorithm which obtains these subgraphs and also groups them in isomorphism classes