Knowledge discovery in structured databases is very important nowadays. In the last years, graph-based data mining algorithms have used artificial neural networks as tools to support clustering. Several of these algorithms have obtained promising results, but they show expensive computational costs. In this work we introduce an algorithm for clustering graphs based on a SOM network, which is part of a process for discovering useful frequent patterns in large graph databases. Our algorithm is able to handle non-directed, cyclic graphs with labels in vertices and edges. An important characteristic is that it presents polynomial computational complexity, because it uses as input a feature vector built with the spectra of the Laplacian of an adjacent matrix. Such matrix contains codes representing the labels in the graph, which preserves the semantic information included in the graphs to be grouped. We tested our algorithm in a small set of graphs and in a large structured database, finding that it creates meaningful groups of graphs.