public AddDependency ( string from, string to ) : bool | ||
from | string | |
to | string | |
return | bool |
public virtual bool AddDependency(string from, string to)
{
if (_dict.Keys.Contains(from) && !_dict.Keys.Contains(to))
{
_items.Insert(_items.IndexOf(from), to);
_dict[to] = true;
return true;
}
else if (_dict.Keys.Contains(to) && !_dict.Keys.Contains(from))
{
_items.Insert(_items.IndexOf(to) + 1, from);
_dict[from] = true;
return true;
}
else if(_dict.Count == 0)
{
_items.Add(to);
_items.Add(from);
_dict[to] = true;
_dict[from] = true;
return true;
}
return false;
}
public virtual void Add(string from, string to) { var graph = GetGraph(from, to); if (graph != null) { graph.AddDependency(from, to); SetGraph(from, graph); SetGraph(to, graph); return; } var newGraph = new DependencyGraph(); newGraph.AddDependency(from, to); _graphsDictionary.Add(from, newGraph); _graphsDictionary.Add(to, newGraph); _graphs.Add(newGraph); }