예제 #1
0
        public string[] GetOrder(Q07_Graph graph)
        {
            List <Q07_Project> projectsByOrder = new List <Q07_Project>();

            AddNonDependent(projectsByOrder, graph.Graph);

            int toBeProcessed = 0;

            while (toBeProcessed < graph.Graph.Count)
            {
                if (projectsByOrder.Count <= toBeProcessed)
                {
                    return(null);
                }

                Q07_Project current = projectsByOrder[toBeProcessed];

                foreach (Q07_Project project in current.Connections)
                {
                    project.DecrementDependencies();
                }

                AddNonDependent(projectsByOrder, current.Connections);

                toBeProcessed++;
            }

            string[] result = new string[projectsByOrder.Count];
            for (int i = 0; i < projectsByOrder.Count; i++)
            {
                result[i] = projectsByOrder[i].Name;
            }

            return(result);
        }
예제 #2
0
        public void AddConnectionsByName(string parentName, string childName)
        {
            Q07_Project childProject  = GetOrCreateByName(childName);
            Q07_Project parentProject = GetOrCreateByName(parentName);

            parentProject.AddConnection(childProject);
        }
예제 #3
0
        public Q07_Project GetOrCreateByName(string name)
        {
            foreach (Q07_Project current in graph)
            {
                if (current.Name == name)
                {
                    return(current);
                }
            }

            Q07_Project project = new Q07_Project(name);

            graph.Add(project);

            return(project);
        }
예제 #4
0
 public void AddConnection(Q07_Project project)
 {
     connections.Add(project);
     project.IncrementDependencies();
 }