You are given the next map where many flags are shown on their corresponding countries.
Construct a forest of maximal weight such that:
- There exist at most one edge between two flags if and only if the associated countries share at least one border. For instance, France and Belgium could be linked. Island must be a single node tree because it does not share any border.
- The weight of any edge is the sum of the number of colors on the two flags. France's flag has 3 colors and Belgium's flag also has 3 colors, which means that linking France to Belgium will weight 6 in the objective.
To help you more: Portugal has 6 colors on its flag and Spain 2, you must link the two countries in a maximal solution and the associated edge will weight 6+2=8 in the objective!
To help you even more
As a starting point and to illustrate the requirements here is an obviously non-optimal solution of value 115. You can optimize it in GeoGebra here.
European Countries and Number of Different Colors in Their Flags (please discard any unnecessary occurrence or add one if necessary)
- Albania – 2 colors (red, black)
- Andorra – 4 colors (blue, yellow, red, white)
- Armenia – 3 colors (red, blue, orange)
- Austria – 2 colors (red, white)
- Azerbaijan – 4 colors (blue, red, green, white)
- Belarus – 4 colors (red, green, white, pink pattern)
- Belgium – 3 colors (black, yellow, red)
- Bosnia and Herzegovina – 3 colors (blue, yellow, white)
- Bulgaria – 3 colors (white, green, red)
- Croatia – 5 colors (red, white, blue, black, yellow)
- Cyprus – 3 colors (white, copper-orange, green)
- Czech Republic – 3 colors (white, red, blue)
- Denmark – 2 colors (red, white)
- Estonia – 3 colors (blue, black, white)
- Finland – 2 colors (white, blue)
- France – 3 colors (blue, white, red)
- Georgia – 2 colors (white, red)
- Germany – 3 colors (black, red, yellow)
- Greece – 2 colors (blue, white)
- Hungary – 3 colors (red, white, green)
- Iceland – 3 colors (blue, white, red)
- Ireland – 3 colors (green, white, orange)
- Italy – 3 colors (green, white, red)
- Kazakhstan (partly in Europe) – 2 colors (sky blue, gold)
- Kosovo – 3 colors (blue, yellow, white)
- Latvia – 2 colors (red, white)
- Liechtenstein – 3 colors (blue, red, yellow)
- Lithuania – 3 colors (yellow, green, red)
- Luxembourg – 3 colors (red, white, light blue)
- Malta – 3 colors (white, red, gray/silver for cross)
- Moldova – 4 colors (blue, yellow, red, brown/gold for emblem)
- Monaco – 2 colors (red, white)
- Montenegro – 4 colors (red, gold/yellow, blue, white)
- Netherlands – 3 colors (red, white, blue)
- North Macedonia – 2 colors (red, yellow)
- Norway – 3 colors (red, white, blue)
- Poland – 2 colors (white, red)
- Portugal – 4 colors (green, red, yellow, white)
- Romania – 3 colors (blue, yellow, red)
- Russia – 3 colors (white, blue, red)
- San Marino – 3 colors (white, light blue, yellow/gold)
- Serbia – 4 colors (red, blue, white, yellow/gold)
- Slovakia – 4 colors (white, blue, red, yellow)
- Slovenia – 4 colors (white, blue, red, yellow)
- Spain – 3 colors (red, yellow, white)
- Sweden – 2 colors (blue, yellow)
- Switzerland – 2 colors (red, white)
- Turkey – 2 colors (red, white)
- Ukraine – 2 colors (blue, yellow)
- United Kingdom – 3 colors (red, white, blue)
- Vatican City – 2 colors (yellow, white)



