Question: Is there a non manual way to control the colour ramp in symbology based on value.

In my example below I have values that can be positive or negative, i want everything positive to be one colour and negative the other with values around zero as white.

[![enter image description here](https://i.stack.imgur.com/WxVny.png)](https://i.stack.imgur.com/WxVny.png)

How does QGIS decide where to place the break in colour? Double clicking on the ramp brings me this set of options but the figures at bottom don't correspond to the figures in the source data.

[![enter image description here](https://i.stack.imgur.com/vRP0g.png)](https://i.stack.imgur.com/vRP0g.png)

Answer given by Eric below, screen grab is that applied to my example for those who can't translate the German. This still leaves you with some manual edits to make, for most automated solution see my solution

[![enter image description here](https://i.stack.imgur.com/avaBv.png)](https://i.stack.imgur.com/avaBv.png)

Answer: 
The key here is to collect the visited edges into a path array and check against that in each iteration. Try

```
WITH RECURSIVE
  connected_line AS (
    SELECT 0 AS it,
           ARRAY[a.id] AS path,
           a.geom AS geom
    FROM network a
    WHERE id = 1
  UNION ALL
    SELECT c.it + 1 AS it
           array_append(c.path, b.id) AS path,
           b.geom AS geom
    FROM network b
    JOIN connected_line c
      ON ST_Intersects(b.geom, c.geom)
     AND b.id <> ALL(c.path)
)
SELECT it,
       path,
       geom
FROM connected_line;

```

**Note:**  

This approach works if there is always exactly one connected edge that has not yet been found. However, it produces one path for each branch when the network forks and will find already visited edges when they were found in different paths.  

If your question is answered by simply finding *all connected sub-networks* and get the longest, try `ST_ClusterDBSCAN` with `eps := 0` and search for the max `ST_Length` of the clusters collected components. This way, you could also specify attributes to cluster (i.e. specify the sub-network type) for if you need to (in the mandatory `OVER()` clause, e.g. `OVER(PARTITION BY <attribute>`).
As suggested by @ThingumaBob, I resolved my problem with `ST_ClusterDBSCAN` (postgis 9.3 and above).

So I select the line's ID which are included in the longest subnetwork with:

```
WITH subnetwork AS
(
   SELECT gid, ST_CLUSTERDBSCAN(geom, eps := 0.0, minpoints := 1) OVER () AS sub, ST_LENGTH(geom) AS len
   FROM network
) 
SELECT gid FROM subnetwork
WHERE sub = (SELECT sub FROM (SELECT sub, SUM(len) AS t_len FROM subnetwork GROUP BY sub ORDER BY t_len DESC LIMIT 1) AS temp)

```