protected void Render(IEnumerable <Dependency> edges, ItemMatch innerMatchOrNull,
                              [NotNull] ITargetWriter output, int?labelWidthOrNull, bool withNotOkCt)
        {
            IDictionary <Item, IEnumerable <Dependency> > itemsAndDependencies = Dependency.Dependencies2ItemsAndDependencies(edges);

            var innerAndReachableOuterItems =
                new HashSet <Item>(itemsAndDependencies.Where(n => ItemMatch.IsMatch(innerMatchOrNull, n.Key)).SelectMany(kvp => new[] { kvp.Key }.Concat(kvp.Value.Select(e => e.UsedItem))));

            IEnumerable <Item> sortedItems = MoreOrLessTopologicalSort(edges).Where(n => innerAndReachableOuterItems.Contains(n));

            if (sortedItems.Any())
            {
                int m = 0;
                Dictionary <Item, int> item2Index = sortedItems.ToDictionary(n => n, n => ++ m);

                IEnumerable <Item> topItems = sortedItems.Where(n => ItemMatch.IsMatch(innerMatchOrNull, n));

                int labelWidth = labelWidthOrNull ?? Math.Max(Math.Min(sortedItems.Max(n => n.Name.Length), 30), 4);
                int colWidth   = Math.Max(1 + ("" + edges.Max(e => e.Ct)).Length, // 1+ because of loop prefix
                                          1 + ("" + sortedItems.Count()).Length); // 1+ because of ! or % marker
                string itemFormat = "{0," + (colWidth - 1) + ":" + Repeat('0', colWidth - 1) + "}";
                string ctFormat   = "{0}{1," + (colWidth - 1) + ":" + Repeat('#', colWidth) + "}";

                Write(output, colWidth, labelWidth, topItems, itemFormat, item2Index, withNotOkCt, sortedItems, ctFormat, itemsAndDependencies);
            }
            else
            {
                Log.WriteError("No visible items and dependencies found for output");
            }
        }
예제 #2
0
        private void Render([NotNull, ItemNotNull] IEnumerable <Dependency> dependencies, [NotNull] ITargetWriter output, ItemMatch innerMatch, int?maxExampleLength)
        {
            IDictionary <Item, IEnumerable <Dependency> > itemsAndDependencies = Dependency.Dependencies2ItemsAndDependencies(dependencies);

            output.WriteLine("digraph D {");
            output.WriteLine("ranksep = 1.5;");

            foreach (var n in itemsAndDependencies.Keys.OrderBy(n => n.Name))
            {
                output.WriteLine("\"" + n.Name + "\" [shape=" + (ItemMatch.IsMatch(innerMatch, n) ? "box,style=bold" : "oval") + "];");
            }

            output.WriteLine();

            foreach (var n in itemsAndDependencies.Keys.OrderBy(n => n.Name))
            {
                foreach (var e in itemsAndDependencies[n].Where(e => ItemMatch.IsMatch(innerMatch, e.UsingItem) || ItemMatch.IsMatch(innerMatch, e.UsedItem)))
                {
                    output.WriteLine(e.GetDotRepresentation(maxExampleLength));
                }
            }

            output.WriteLine("}");
        }