# Is there a way to update a graph in place?

I'm assembling graphs programmatically, and looping through EdgeAdd[] a lot.

graph = EdgeAdd[graph, a -> b];


Is there a more efficient way to do the updates "in place" -- as opposed to the normal assignment?

• Graphs are immutable objects ... so the general answer is "no". But perhaps there may be some trick on your particular situation. Tell us more about what you're trying to do – Dr. belisarius Dec 18 '15 at 5:43
• Welcome to Mathematica.SE! 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – user9660 Dec 18 '15 at 7:01
• You can use sparse arrays to represent graphs. The question is: what else do you want to do with the graphs in the inner loop other than EdgeAdd and whether that thing is easy/fast with a sparse array. – Szabolcs Dec 18 '15 at 8:30
• I'm trying to assemble the graph from a list of associations. I was hoping to use something analogous to the AppendTo[] function. I don't have the list of associations when the graph is initially created. Thanks. – vonkohorn Dec 18 '15 at 9:28