A method for clustering a plurality of data graphs, wherein the plurality of data graphs are comprised of image primitives and relations, said method comprising: generating, by a processing device, a graph lattice comprised of a graph of related subgraphs, wherein subgraphs of degree 1 are the primitives and each subgraph of degree i > 1 is comprised of a subgraph of degree i -1 and one of the primitives, wherein the graph lattice is a lattice of nodes, and wherein each node corresponds to a subgraph representing image primitives and relations, and each graph lattice node is configured to provide descriptive information about the subgraph to which the graph lattice node corresponds; generating at least one strut consisting of a parent graph lattice node at a level N, a primitive, and a child graph lattice node at level N+1 which is the subgraph consisting of the parent graph lattice node subgraph plus the primitive linked to the perimeter of the parent graph lattice node subgraph; computing mappings of primitives to nodes of the data graph by mapping the junctions of the nodes to corresponding junctions of the data graph; computing mappings of subgraphs of degree 2 to the data graph by, for each pair of primitives which are parent graph lattice nodes of one or more struts to one or more level 2 graph lattice nodes, identifying mappings of the first of the pair of primitives for which the data graph contains a link to the second of the primitives; iteratively computing mappings of subgraphs of degree 3 and higher by, for each graph lattice node at level N > 2, selecting a strut to a parent node of the graph lattice node, and for each of the mappings of the parent node, identifying if the primitive associated with the strut is present in the data graph and is linked; generating, by a processing device, feature vectors for the plurality of data graphs, such that each graph lattice node comprises one element of the feature vector, where the entry for each element in the feature vector is the number of mappings of the graph lattice node subgraph onto the data graph; and, clustering, by a processing device, the plurality of data graphs according to similarity between the generated feature vectors. generating, by a processing device, a graph lattice comprised of a graph of related subgraphs, wherein subgraphs of degree 1 are the primitives and each subgraph of degree i > 1 is comprised of a subgraph of degree i -1 and one of the primitives, wherein the graph lattice is a lattice of nodes, and wherein each node corresponds to a subgraph representing image primitives and relations, and each graph lattice node is configured to provide descriptive information about the subgraph to which the graph lattice node corresponds; generating at least one strut consisting of a parent graph lattice node at a level N, a primitive, and a child graph lattice node at level N+1 which is the subgraph consisting of the parent graph lattice node subgraph plus the primitive linked to the perimeter of the parent graph lattice node subgraph; computing mappings of primitives to nodes of the data graph by mapping the junctions of the nodes to corresponding junctions of the data graph; computing mappings of subgraphs of degree 2 to the data graph by, for each pair of primitives which are parent graph lattice nodes of one or more struts to one or more level 2 graph lattice nodes, identifying mappings of the first of the pair of primitives for which the data graph contains a link to the second of the primitives; iteratively computing mappings of subgraphs of degree 3 and higher by, for each graph lattice node at level N > 2, selecting a strut to a parent node of the graph lattice node, and for each of the mappings of the parent node, identifying if the primitive associated with the strut is present in the data graph and is linked; generating, by a processing device, feature vectors for the plurality of data graphs, such that each graph lattice node comprises one element of the feature vector, where the entry for each element in the feature vector is the number of mappings of the graph lattice node subgraph onto the data graph; and, clustering, by a processing device, the plurality of data graphs according to similarity between the generated feature vectors.