### Generating a unique file name for each graph

I am writing a function whose input is a graph and some other data. I would like to store the computations that this program does each time it is run in a file with one file for each graph, so that, the next time it is run, it need not recalculate the calculations it has already done. In order to do this, I would like to assign a unique file name to each graph. I was thinking of using the hash function of the combinatorial object constructed from the graph to generate file names: `CombinatorialObject(G).__hash__()`

I have two questions:

Will this always work (the function taking a graph to this has is well-defined and injective)?

Is there a better way to do this?