/// <summary>
        /// Returns all nodes in the schedule whose target appears prior to the node.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="schedule"></param>
        /// <returns></returns>
        internal static Set <NodeIndex> CollectUses(IndexedGraph g, IEnumerable <NodeIndex> schedule)
        {
            Set <NodeIndex> uses      = new Set <NodeIndex>();
            Set <NodeIndex> available = new Set <NodeIndex>();

            foreach (NodeIndex node in schedule)
            {
                foreach (NodeIndex source in g.SourcesOf(node))
                {
                    if (!available.Contains(source))
                    {
                        uses.Add(source);
                    }
                }
                available.Add(node);
            }
            return(uses);
        }