@@ -14,32 +14,26 @@ public class MColorer<T, C>
1414 /// </summary>
1515 public MColorResult < T , C > Color ( IGraph < T > graph , C [ ] colors )
1616 {
17- var totalProgress = new Dictionary < IGraphVertex < T > , C > ( ) ;
17+ var progress = new Dictionary < IGraphVertex < T > , C > ( ) ;
1818
1919 foreach ( var vertex in graph . VerticesAsEnumberable )
2020 {
21- var progress = canColor ( vertex , colors ,
22- new Dictionary < IGraphVertex < T > , C > ( ) ,
23- new HashSet < IGraphVertex < T > > ( ) ) ;
24-
25- foreach ( var item in progress )
21+ if ( ! progress . ContainsKey ( vertex ) )
2622 {
27- if ( ! totalProgress . ContainsKey ( item . Key ) )
28- {
29- totalProgress . Add ( item . Key , item . Value ) ;
30- }
23+ canColor ( vertex , colors ,
24+ progress ,
25+ new HashSet < IGraphVertex < T > > ( ) ) ;
3126 }
32-
3327 }
3428
35- if ( totalProgress . Count != graph . VerticesCount )
29+ if ( progress . Count != graph . VerticesCount )
3630 {
3731 return new MColorResult < T , C > ( false , null ) ;
3832 }
3933
4034 var result = new Dictionary < C , List < T > > ( ) ;
4135
42- foreach ( var vertex in totalProgress )
36+ foreach ( var vertex in progress )
4337 {
4438 if ( ! result . ContainsKey ( vertex . Value ) )
4539 {
0 commit comments