@@ -14,32 +14,26 @@ public class MColorer<T, C>
14
14
/// </summary>
15
15
public MColorResult < T , C > Color ( IGraph < T > graph , C [ ] colors )
16
16
{
17
- var totalProgress = new Dictionary < IGraphVertex < T > , C > ( ) ;
17
+ var progress = new Dictionary < IGraphVertex < T > , C > ( ) ;
18
18
19
19
foreach ( var vertex in graph . VerticesAsEnumberable )
20
20
{
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 ) )
26
22
{
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 > > ( ) ) ;
31
26
}
32
-
33
27
}
34
28
35
- if ( totalProgress . Count != graph . VerticesCount )
29
+ if ( progress . Count != graph . VerticesCount )
36
30
{
37
31
return new MColorResult < T , C > ( false , null ) ;
38
32
}
39
33
40
34
var result = new Dictionary < C , List < T > > ( ) ;
41
35
42
- foreach ( var vertex in totalProgress )
36
+ foreach ( var vertex in progress )
43
37
{
44
38
if ( ! result . ContainsKey ( vertex . Value ) )
45
39
{
0 commit comments