/// <summary> /// REFACTOR NEEDED @#$%@$%^&#%^&*@$#@ /// it's late, i'm tired, i don't care - but it's crap :/ /// </summary> public string Find(Dictionary <Vertex, byte> degrees, List <Edge> edges, EulerCycleResultType type) { if (ValidateType(type)) { return(string.Empty); } Stack <KeyValuePair <Vertex, byte> > stack = new Stack <KeyValuePair <Vertex, byte> >(); List <KeyValuePair <Vertex, byte> > solution = new List <KeyValuePair <Vertex, byte> >(); List <Edge> edgesCopy = new List <Edge>(edges); var analyzedVertex = degrees.FirstOrDefault(); solution.Add(analyzedVertex); while (true) { while (analyzedVertex.Value != ISOLATED_DEGREE) { KeyValuePair <Edge, KeyValuePair <Vertex, byte> > incident = FindIncident(degrees, edgesCopy, analyzedVertex.Key); if (incident.Key == null) { break; } stack.Push(analyzedVertex); edgesCopy.Remove(incident.Key); analyzedVertex = incident.Value; } if (stack.Any()) { analyzedVertex = stack.Pop(); solution.Add(analyzedVertex); } else { break; } } return(string.Join(LIST_SEPARATOR, solution.Select(x => x.Key.Id))); }
private bool ValidateType(EulerCycleResultType type) { return(_unsupportedTypes.Contains(type)); }