There is a tool Topological coloring
, however only for polygons, not lines. You could still use it:
Create a (small) buffer around your lines.
Apply
Menu Processing / Toolbox / Topological coloring
to the buffer: it will create a new attributecolor_id
.Use Categorized styling and set the color to the field
color_id
.Optional: you can join the
color_id
created on your buffer layer back to your original line layer withJoin attributes by location
The screenshot shows the solution using buffers: if they are small enough, they appear as lines: