Skip to content

Commit

Permalink
Merge branch 'master' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
justcoding121 committed Oct 10, 2020
2 parents 7185d3c + c9468b3 commit 0d78bec
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/Advanced.Algorithms/Graph/Coloring/MColorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,26 @@ public class MColorer<T, C>
/// </summary>
public MColorResult<T, C> Color(IGraph<T> graph, C[] colors)
{
var totalProgress = new Dictionary<IGraphVertex<T>, C>();
var progress = new Dictionary<IGraphVertex<T>, C>();

foreach (var vertex in graph.VerticesAsEnumberable)
{
var progress = canColor(vertex, colors,
new Dictionary<IGraphVertex<T>, C>(),
new HashSet<IGraphVertex<T>>());

foreach(var item in progress)
if (!progress.ContainsKey(vertex))
{
if (!totalProgress.ContainsKey(item.Key))
{
totalProgress.Add(item.Key, item.Value);
}
canColor(vertex, colors,
progress,
new HashSet<IGraphVertex<T>>());
}

}

if (totalProgress.Count != graph.VerticesCount)
if (progress.Count != graph.VerticesCount)
{
return new MColorResult<T, C>(false, null);
}

var result = new Dictionary<C, List<T>>();

foreach (var vertex in totalProgress)
foreach (var vertex in progress)
{
if (!result.ContainsKey(vertex.Value))
{
Expand Down

0 comments on commit 0d78bec

Please sign in to comment.