Beispiel #1
0
        public String ToDot(IComponent component)
        {
            var sb = new StringBuilder();

            sb.Append("digraph propNet\n{\n");
            sb.Append("\t" + component.ToDot() + "\n");

            Queue<IComponent> queue = new Queue<IComponent>();
            foreach (IComponent current in component.Inputs)
                queue.Enqueue(current);

            var done = new HashSet<IComponent>();

            while (queue.Count > 0)
            {
                IComponent current = queue.Dequeue();
                if (done.Contains(current))
                    continue;

                sb.Append("\t" + current.ToDot() + "\n");

                done.Add(current);

                if (current is ITransition)
                    continue;

                foreach (IComponent input in current.Inputs)
                    queue.Enqueue(input);
            }

            sb.Append("}");

            return sb.ToString();
        }