add edges into a graph gets slower and slower

Topics: graph
Apr 18, 2013 at 9:03 PM
I try to add around 200k edges (of SEdge<int> type) into a AdjacencyGraph<int, SEdge<int>>.

It quickly finishes the first 10% but gets slower after that. It takes me around 20 mins to add all those edges into the graph. Below is my code. My question is, am I do anything wrong? Are there any way to speed up my process. My graph actually is a immutable graph. But I simply use mutable graph here because it has a few working example.
        userGraph = new AdjacencyGraph<int, SEdge<int>>();
        userGraph.AddVertexRange(index.usermap.addr2uid.Values); // addr2uid is a dictionary contains all vertices
        for (int i = 0; i < index.weights.weights.Count; i++) //index.weight.weights is another dictionary contains all Edge<->weight mappings.
            int source = index.weights.weights.ElementAt(i).Key.source;
            int target = index.weights.weights.ElementAt(i);
            SEdge<int> v_edge = new SEdge<int>(source,target);
Any suggestion is highly appreciated!