(nodeLen, sources, targets)
| 146 | } |
| 147 | |
| 148 | function circularityPresent(nodeLen, sources, targets) { |
| 149 | var nodes = Lib.init2dArray(nodeLen, 0); |
| 150 | |
| 151 | for(var i = 0; i < Math.min(sources.length, targets.length); i++) { |
| 152 | if(Lib.isIndex(sources[i], nodeLen) && Lib.isIndex(targets[i], nodeLen)) { |
| 153 | if(sources[i] === targets[i]) { |
| 154 | return true; // self-link which is also a scc of one |
| 155 | } |
| 156 | nodes[sources[i]].push(targets[i]); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | var scc = tarjan(nodes); |
| 161 | |
| 162 | // Tarján's strongly connected components algorithm coded by Mikola Lysenko |
| 163 | // returns at least one non-singular component if there's circularity in the graph |
| 164 | return scc.components.some(function(c) { |
| 165 | return c.length > 1; |
| 166 | }); |
| 167 | } |
| 168 | |
| 169 | module.exports = function calc(gd, trace) { |
| 170 | var result = convertToD3Sankey(trace); |
no outgoing calls
no test coverage detected
searching dependent graphs…