private void AddTypeEdge(GcType source, GcType target) { GcTypeEdge edge; if (!this.graph.TryGetEdge(source, target, out edge)) this.graph.AddEdge(edge = new GcTypeEdge(source, target)); edge.Count++; }
public GcTypeHeap Merge(int minimumSize) { var merged = new BidirectionalGraph<GcType,MergedEdge<GcType,GcTypeEdge>>(false, this.graph.VertexCount); var merger = new EdgeMergeCondensationGraphAlgorithm<GcType, GcTypeEdge>( this.graph, merged, delegate(GcType type) { return type.Size >= minimumSize; }); merger.Compute(); var clone = new BidirectionalGraph<GcType, GcTypeEdge>( false, merged.VertexCount); foreach (var type in merged.Vertices) clone.AddVertex(type); foreach (var medge in merged.Edges) { GcTypeEdge edge = new GcTypeEdge(medge.Source, medge.Target); foreach (GcTypeEdge e in medge.Edges) edge.Count += e.Count; clone.AddEdge(edge); } Console.WriteLine("resulting {0} types, {1} edges", clone.VertexCount, clone.EdgeCount); return new GcTypeHeap(clone); }