private void buildGraph() { //create the nodes foreach (ASystem sys in unsorted) { //create the node DiGraph<ASystem>.Node node = new DiGraph<ASystem>.Node(sys); //add it to the data structures graph.nodes.Add(node); nodeLookup[sys.GetType()] = node; } //create the edges foreach (DiGraph<ASystem>.Node node in graph.nodes) { //for each system that must run after this one foreach (Type childSystem in node.data.GetChildren()) { //create an edge from that system to this one to indicate that dependency DiGraph<ASystem>.Node childNode = nodeLookup[childSystem]; childNode.AddNeighbor(node); } //for each system that must run before this one foreach (Type parentSystem in node.data.GetParents()) { //create an edge from this system to that one to indicate that dependency DiGraph<ASystem>.Node parentNode = nodeLookup[parentSystem]; node.AddNeighbor(parentNode); } } }