code: def add_graph(patterns, G):
      
      if not patterns:
          patterns.append([G])
          return
      for i, graphs in enumerate(patterns):
          if networkx.is_isomorphic(graphs[0], G, node_match=type_match,
                                    edge_match=type_match):
              patterns[i].append(G)
              return
      patterns.append([G])
docs: Add a graph to a set of unique patterns.