@@ -0,0 +1,849 @@
+package parser.model;%0A%0Aimport java.util.ArrayList;%0A%0Apublic class FindBubbles %7B%0A%09%0A%09private Graph graph;%0A%09%0A%09public FindBubbles(Graph graph) %7B%0A%09%09this.graph = graph;%0A%09%7D%0A%09%0A%09public void calculateFlows() %7B%0A%09%09sendFlow();%0A%09%7D%0A%09%0A%09private void sendFlow() %7B%0A%09%09double flowStart = (double)graph.getSize();%0A%09%09graph.getRoot().setFlow(flowStart);%0A%09%09%0A%09%09for (Node node : graph.getNodes()) %7B%0A%09%09%09System.out.println(node);%0A%09%09%09ArrayList%3CEdge%3E outEdges = node.getOut();%0A%09%09%09double remainingFlow = node.getFlow();%0A%09%09%09%0A%09%09%09for (int i = 0; i %3C outEdges.size(); i++) %7B%0A%09%09%09%09Node target = outEdges.get(i).getTarget();%0A%09%09%09%09%0A%09%09%09%09if (i == node.getOut().size() - 1) %7B%0A%09%09%09%09%09target.addFlow(remainingFlow);%0A%09%09%09%09%7D else %7B%0A%09%09%09%09%09double random = Math.random();%0A%09%09%09%09%09double flowToAdd = random * remainingFlow;%0A%09%09%09%09%09remainingFlow -= flowToAdd;%0A%09%09%09%09%09target.addFlow(flowToAdd);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%7D%0A

Send flow through graph to easily detect what bubbles there are