Question: Any help getting me to starting point on this would really be helpfull, thank you in advance! using System; using System.Collections.Generic; using System.Linq; using System.Text;

Any help getting me to starting point on this would really be helpfull, thank you in advance!

using System; using System.Collections.Generic; using System.Linq; using System.Text;

namespace SpreadsheetUtilities {

///

/// (s1,t1) is an ordered pair of strings /// t1 depends on s1; s1 must be evaluated before t1 /// /// A DependencyGraph can be modeled as a set of ordered pairs of strings. Two ordered pairs /// (s1,t1) and (s2,t2) are considered equal if and only if s1 equals s2 and t1 equals t2. /// Recall that sets never contain duplicates. If an attempt is made to add an element to a /// set, and the element is already in the set, the set remains unchanged. /// /// Given a DependencyGraph DG: /// /// (1) If s is a string, the set of all strings t such that (s,t) is in DG is called dependents(s). /// (The set of things that depend on s) /// /// (2) If s is a string, the set of all strings t such that (t,s) is in DG is called dependees(s). /// (The set of things that s depends on) // // For example, suppose DG = {("a", "b"), ("a", "c"), ("b", "d"), ("d", "d")} // dependents("a") = {"b", "c"} // dependents("b") = {"d"} // dependents("c") = {} // dependents("d") = {"d"} // dependees("a") = {} // dependees("b") = {"a"} // dependees("c") = {"a"} // dependees("d") = {"b", "d"} /// public class DependencyGraph { private Dictionary> dependents, dependees; private int count = 0; /// 0 /// Creates an empty DependencyGraph. /// public DependencyGraph() { dependents = new Dictionary>(); dependees = new Dictionary>(); }

///

/// The number of ordered pairs in the DependencyGraph. /// public int Size { get { return count; } }

///

/// The size of dependees(s). /// This property is an example of an indexer. If dg is a DependencyGraph, you would /// invoke it like this: /// dg["a"] /// It should return the size of dependees("a") /// public int this[string s] {

get {

if(s.Equals(dependees.Values) { return count; } else { return 0; } } }

///

/// Reports whether dependents(s) is non-empty. /// public bool HasDependents(string s) {

if (String.IsNullOrEmpty(s)) { return false; } if (dependees.ContainsKey(s) && dependees[s].Count > 0) { return true; } return false; }

///

/// Reports whether dependees(s) is non-empty. /// public bool HasDependees(string s)

{ if (String.IsNullOrEmpty(s)) { return false; } if (dependents.ContainsKey(s) && dependents[s].Count > 0) { return true; } return false; }

///

/// Enumerates dependents(s). /// public IEnumerable GetDependents(string s) { return null; }

///

/// Enumerates dependees(s). /// public IEnumerable GetDependees(string s) { return null; }

///

/// Adds the ordered pair (s,t), if it doesn't exist /// /// This should be thought of as: /// /// t depends on s /// /// /// s must be evaluated first. T depends on S /// t cannot be evaluated until s is /// public void AddDependency(string s, string t) { }

///

/// Removes the ordered pair (s,t), if it exists /// /// /// public void RemoveDependency(string s, string t) { }

///

/// Removes all existing ordered pairs of the form (s,r). Then, for each /// t in newDependents, adds the ordered pair (s,t). /// public void ReplaceDependents(string s, IEnumerable newDependents) { }

///

/// Removes all existing ordered pairs of the form (r,s). Then, for each /// t in newDependees, adds the ordered pair (t,s). /// public void ReplaceDependees(string s, IEnumerable newDependees) { }

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!