/// <summary>
        /// Returns true if circuit (graph) has a cycle.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public bool LookForCycle(IHavePins g, List <IHavePins> list)
        {
            List <IHavePins> Marked = new List <IHavePins>(list);

            foreach (IHavePins ihp in Marked)
            {
                if (Object.ReferenceEquals(g, ihp))
                {
                    return(true);
                }
            }

            Marked.Add(g);

            foreach (InputPin ip in g.InputPins)
            {
                foreach (Connection c in ip.Connections)
                {
                    if (LookForCycle(c.OutputPin.Owner, Marked))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #2
0
 public InputPin(IHavePins owner) : base()
 {
     Owner = owner;
 }