public bool Equals(Tags tags) { return(_Id == tags._Id); }
public DirectedEdge(Tags target) { Target = target; Directionality = 0; }
public void Add(Tags to) { Add(new DownwardEdge(From, to)); }
public DownwardEdges(Tags from) { From = from; }
public DownwardEdge(Tags from, Tags to) { From = from; To = to; }
private static Tags?ToposortVisit(Dictionary <Tags, DownwardEdges> allEdges, Tags tag, bool isTopLevel, int[] result, Dictionary <int, bool> state, ref int nextIndex) { var id = tag.Id; bool visiting; if (state.TryGetValue(id, out visiting)) { if (visiting) { if (Tracing) { Console.WriteLine("{0}Cycle @{1}", new string('.', Depth + 1), tag); } // HACK: Break this cycle. return(tag); } else { return(null); } } if (Tracing) { Console.WriteLine("{0}{1}", new string('.', Depth), tag); } Depth++; state[id] = true; bool aborted = false; DownwardEdges downwardEdges; Tags?cycle = null; if (allEdges.TryGetValue(tag, out downwardEdges)) { foreach (var edge in downwardEdges) { cycle = ToposortVisit(allEdges, edge.To, false, result, state, ref nextIndex); // We hit a cycle, so we bail out. if (cycle.HasValue) { if (state[id] == true) { state.Remove(id); } Depth--; // We don't propagate the cycle, though. return(null); } } } Assign(tag, result, state, ref nextIndex); Depth--; return(cycle); }