private GcTypeHeap TouchingInPlace(string typeNames)
{
if (String.IsNullOrEmpty(typeNames))
throw new ArgumentNullException("typeNames");
var filter = FilterHelper.ToFilter(typeNames);
Console.WriteLine("filtering nodes not connected to type matching '{0}'", filter);
var colors = new Dictionary<GcType, GraphColor>(this.graph.VertexCount);
foreach (var type in this.graph.Vertices)
colors.Add(type, GraphColor.White);
var rgraph = new ReversedBidirectionalGraph<GcType, GcTypeEdge>(graph);
foreach (var type in this.graph.Vertices)
{
if (filter.Match(type.Name))
{
{ // parents
var dfs =
new DepthFirstSearchAlgorithm<GcType, ReversedEdge<GcType, GcTypeEdge>>(rgraph, colors);
dfs.Visit(type);
}
{ // children
var dfs = new DepthFirstSearchAlgorithm<GcType, GcTypeEdge>(graph, colors);
dfs.Visit(type);
}
}
}
// remove all white vertices
this.graph.RemoveVertexIf(t => colors[t] == GraphColor.White);
Console.WriteLine("resulting {0} types, {1} edges", graph.VertexCount, graph.EdgeCount);
return this;
}