MCPcopy Create free account
hub / github.com/plotly/plotly.js / circularityPresent

Function circularityPresent

src/traces/sankey/calc.js:148–167  ·  view source on GitHub ↗
(nodeLen, sources, targets)

Source from the content-addressed store, hash-verified

146}
147
148function 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
169module.exports = function calc(gd, trace) {
170 var result = convertToD3Sankey(trace);

Callers 1

convertToD3SankeyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…