Hi, I’d been trying to solve the Advent of Code 2024 problems using WL and in particular using graphs where it made sense. One of the solutions I came up with involved creating a 141x141 grid graph, deleting some vertices (leaving ~7000), then adding about 5000 edges.
I got a version of this working so that it made one call to VertexDelete and one call to EdgeAdd and then 5000 calls to AnnotationValue[]= to set the edge weights. This took about 15 hours to run on my PC, which is just unbelievably slow.
After a lot of experimentation with different ways to making this more efficient and adding Print functions everywhere to see exactly what is taking the time, virtually all the time is taken in setting the edge weights.
I even tried building a new graph, concatenating the edges from the first graph with the new edges in the form Annotation[edge, EdgeWeight->1002] and that still takes just as long even though it is one call. If I remove the edgeweight annotation from the new edges, it completes almost immediately.
So what’s the deal with graphs with edgeweights being many orders of magnitude slower to build? Note that none of this time includes doing any pathfinding or other graph algorithm. This is 15 hours just to build a graph. Not great.