I generated a very large graph, too large to simply display and manipulate with copy/paste operations. How can I somehow save the graph to a file to allow it to be rapidly reloaded after I quit out of the kernel and restart Mathematica?
1 Answer
From the comments of Spawn1710D and Szabolcs:
Save or DumpSave might be of help. With DumpSave you will have the object saved in an mx file so the size will be smaller and will load faster.
You use
Save["SaveFile.mx",G] , where G is your graph to save and
Get["SaveFile.mx"] or
<<SaveFile.mx to load it. Make sure the file is located inside the path of Mathematica and keep in mind that the file can be loaded only to computers with the same kind of OS, so if you make the mx on windows it won't load in Mac OS.
Instead of DumpSave, Export can be used. It can also write MX files, but doesn't store variable names inside (only the data). Or just use
Export["name.mz", Compress[graph], "String"].
SaveorDumpSavemight be of help. WithDumpSaveyou will have the object saved in an mx file so the size will be smaller and will load faster. $\endgroup$Get["SaveFile.mx"]or<<SaveFile.mxto load it. Make sure the file is located inside the path of Mathematica and keep in mind that the file can be loaded only to computers with the same kind of OS, so if you make the mx on windows it won't load in Mac OS. $\endgroup$DumpSave, I recommendExport, which can also write MX files, but doesn't store variable names inside (only the data). Or just useExport["name.mz", Compress[graph], "String"]. See also here $\endgroup$Export/Importand.mxfiles. I typically useDumpSaveandGetwith a dedicated internal variable and a wrapper function in my packages i.e. something likesave[file_, var_] := Block[{$var}, DumpSave[file, $var = var];]andload[file_] := Block[{$var} = Get@file]. Oh well... I'll probably keep them the way they are, since it works. $\endgroup$