Yes, it is possible (and relatively easily feasible) with d3.js.

Here is an example:

You will most likely need to adjust the code to suit your need, but this is basically a solution to your problem.

Take a look at this random Sankey generator:

After a while you'll get graphs with loops.

Related Query