That's not going to be straightforward indeed... You could try working entirely with a Graph structure. First extract all the connected pixels from the image and insert them in a Graph where neighboring nodes are connected with an edge. You could discard Graphs that are smaller than some M number of nodes (to exclude little spots that are not relevant to the image).
At the end of this process you will have a set of disconnected Graphs. (Judging from your image, these are not exactly Trees because there are cycles in there)
You can find the extremal points of each Graph (the extremal pixels in the periphery of each Graph) by starting from some random node and doing a DFS.
At the end of this process you will have a set of pixel coordinates for each Graph corresponding to the extremal points where connections are more likely to form.
You can now try to connect the nearest extremal point neighbors (with a distance <=5) simply with a straight line.
But, if you want to take into account the slope of the line segment that leads to that extremal pixel you could try to "fit a line" to N pixels PRIOR to reaching that extremal pixel. So if N = 5, then the last 5 pixels of a branch would be used in estimating a line.
Therefore, for each nearest neighbor pair you now also have another thing to use as a criterion to judge if two segments should be connected (i.e. Extremal Point Distance <=5 pixels AND approximately equal line slope).
To minimise the impact of noise that may make your lines appear jagged near the branch's tips (and therefore distort your slope estimation) you could try applying a simplification step to your Graph (this is another point (besides the DFS above) where it pays to work with a Graph structure). You could for example remove subsequent nodes of the Graph that would make the line "bend" at angles greater than some cut-off (for something more complex, please see here). In this way you will be fitting "simpler" lines, roughly to the direction of a larger part of the segment formed by the image pixels.
That will probably result in decent connections for the majority of cases (judging by the image you have posted) but it would still leave you with some challenging ones. For example how would a "Y" shaped interrupted pattern where one of the branches is interrupted near the connection point be connected? (i.e., you have a "continuous" bend that must be connected with a line segment that "blends" with it). Perhaps you could review how common such cases are and revise your connection criteria later.
Also, maybe it would be worth examining how you could improve your image acquisition (increase the resolution for example).