hi ,
i have a table which have values like this :

S11 S2 S9 S20
S11 0 0 2 0
S2 0 0 0 2
S9 2 0 0 2
S20 0 2 2 0

i want to compare columns and rows and assign color to S11,S2 , S9 and S20 and group it using graph coloring method. the value 0 means both 2 S are connected and if 2 its not connected. If the value is 0 the color between those to S must be different and if 2 can be same color but have to make sure the color not had been assigned to other S which are already connected to itself. in this example the Ss will be assigned with 2 colors which means 2 groups. S11 - red, S2 -red, S9 - blue and S20- blue. S2 and S20 not connected so it can be in same color. and same goes to S11 and S9. the final output should be in a table like this:

Column 1(red) Column 2(blue)
S11 S2
S9 S20

it has to be implemented in vb code. anyone please help me for the solution.

Well, start with posting what you tried?

whta's your database ?? sql,access,mysql???

if possible can you provide some code ???

Try yourself, first, at least. Get the records, process them, and do another query to insert the result.