a computer implemented method and system for calculating a degree of similarity between two graphs whose nodes are respectively given discrete labels include providing , for each of the two graphs , label values respectively to a given node and nodes adjacent thereto so that different ones of the discrete labels correspond to different ones of the label values . the nodes are sequentially tracing for each of the two graphs , and , during the tracing of the nodes , a new label value is calculated through a hash calculation using a label value of a currently visited node and also using label values of nodes adjacent to the currently visited node to update the label value to the currently visited node . the degree of similarity between the two graphs is calculated on the basis of the number of the label values having been given to nodes of the two graphs and agreeing between the two graphs .