public static string Create(ConcurrentDictionary <string, ProjectGraphNode> projects, GraphVisOptions options) { HashSet <ProjectGraphNode> seen = new HashSet <ProjectGraphNode>(); var sb = new StringBuilder(); var edges = new StringBuilder(); //var nodes = new StringBuilder(); var clusters = new StringBuilder(); foreach (var group in projects .Where(n => !n.Value.ProjectInstance.FullPath.Contains("dirs.proj")) .GroupBy(kvp => kvp.Value.ProjectInstance.FullPath, (p, plist) => new { ProjectGroupName = p, Projects = projects.Where(p2 => p2.Value.ProjectInstance.FullPath == p).ToList() })) { GraphVisCluster cluster = new GraphVisCluster(@group.ProjectGroupName); foreach (var node in @group.Projects) { var graphNode = new GraphVisNode(node.Value); cluster.AddNode(graphNode); if (seen.Contains(node.Value)) { continue; } seen.Add(node.Value); //nodes.AppendLine(graphNode.Create()); foreach (var subNode in node.Value.ProjectReferences) { var subGraphVisNode = new GraphVisNode(subNode); var edgeString = new GraphVisEdge(graphNode, subGraphVisNode); edges.AppendLine(edgeString.Create()); //if (!seen.Contains(node.Value)) // nodes.AppendLine(subGraphVisNode.Create()); } } clusters.AppendLine(cluster.Create()); } sb.AppendLine("digraph prof {"); sb.AppendLine(" ratio = fill;"); sb.AppendLine($" nodesep = {options.NodeSep};"); sb.AppendLine($" ranksep = {options.RankSep};"); sb.AppendLine(" node [style=filled];"); sb.Append(clusters); sb.Append(edges); sb.AppendLine("}"); GraphVisNode._count = 1; return(sb.ToString()); }
public static string Create(IEnumerable <ProjectGraphNode> graphNodes, GraphVisOptions options) { var graphNodesSet = graphNodes.ToHashSet(); var seen = new HashSet <ProjectGraphNode>(); var sb = new StringBuilder(); var edges = new StringBuilder(); //var nodes = new StringBuilder(); var clusters = new StringBuilder(); foreach (var group in graphNodesSet .GroupBy(n => n.ProjectInstance.FullPath, (p, plist) => new { ProjectGroupName = p, Projects = plist })) { GraphVisCluster cluster = new GraphVisCluster(group.ProjectGroupName); foreach (var node in group.Projects) { var graphNode = new GraphVisNode(node); cluster.AddNode(graphNode); if (seen.Contains(node)) { continue; } seen.Add(node); // skip references not in the set of input nodes, in case a subgraph was given foreach (var subNode in node.ProjectReferences.Where(r => graphNodesSet.Contains(r))) { var subGraphVisNode = new GraphVisNode(subNode); var edgeString = new GraphVisEdge(graphNode, subGraphVisNode); edges.AppendLine(edgeString.Create()); //if (!seen.Contains(node)) // nodes.AppendLine(subGraphVisNode.Create()); } } clusters.AppendLine(cluster.Create()); } sb.AppendLine("digraph prof {"); sb.AppendLine(" ratio = fill;"); sb.AppendLine($" nodesep = {options.NodeSep};"); sb.AppendLine($" ranksep = {options.RankSep};"); sb.AppendLine(" node [style=filled];"); sb.Append(clusters); sb.Append(edges); sb.AppendLine("}"); GraphVisNode._count = 1; return(sb.ToString()); }
public GraphVisEdge(GraphVisNode node1, GraphVisNode node2) { _node1 = node1; _node2 = node2; }
public void AddNode(GraphVisNode node) { _nodes.Add(node); }