Is there a way in QGIS to use an expression to define a polygon feature's color based on whether it's adjacent to other features? I would like to achieve something like the following:
-If a feature has no adjacent features, it gets the default color.
-If two features are adjacent, one gets the default color and the other gets a secondary color.
-If another feature is adjacent to the both of the first two, it gets a tertiary color, and so on.
This is similar to the four-color theorem, except that I want to define the order in which colors are applied, so that the default color is always the first choice and the other colors are given second, third, fourth priority, etc.
The easiest way I can think of is to add a "Color ID" field and manually assign each feature a value of 0, 1, 2 or 3. But can I do this without adding an attribute, just using the existing geometry and searching for shared boundaries?