MCPcopy Create free account
hub / github.com/davidkingzyb/SCAST / _D3Tree2Network

Function _D3Tree2Network

js/D3M.js:307–358  ·  view source on GitHub ↗
(d)

Source from the content-addressed store, hash-verified

305
306 function EdgeBundling(d) {
307 function _D3Tree2Network(d) {
308 var r = []
309 var map = {}
310 for (let n of d.children) {
311 console.log('tree2network',n)
312 if(n.filetype=='js'){
313 ESTREEJS.traverseAst(n, function (node) {
314 if(!node.name)return
315 var nodename=node.name.replace(/[^0-9a-zA-Z]/g, '_')
316 if (gD3.conf.estreeops[node.type] || gD3.conf.estreeops.all) {
317 if (!map['network.' + nodename]) {
318 map['network.' + nodename] = []
319 }
320 if (node.children && node.children.length > 0) {
321 for (let child of node.children) {
322 if(!child||!child.name)continue
323 let childname=child.name.replace(/[^0-9a-zA-Z]/g, '_')
324 if (!map['network.' + childname]) {
325 map['network.' + childname] = []
326 }
327 map['network.' + nodename].push('network.' + childname)
328 }
329 }
330
331 }
332 })
333 }else{
334 SCAST.traverseAst(n, function (node) {
335 if (gD3.conf.scastops[node.type] || gD3.conf.scastops.all) {
336 if (!map['network.' + node.value]) {
337 map['network.' + node.value] = []
338 }
339 if (node.children && node.children.length > 0) {
340 for (let child of node.children) {
341 if (!map['network.' + child.value]) {
342 map['network.' + child.value] = []
343 }
344 map['network.' + node.value].push('network.' + child.value)
345 }
346 }
347
348 }
349 })
350 }
351
352 }
353 for (let k in map) {
354 r.push({ name: k, imports: map[k] })
355 }
356 console.log('2network', r)
357 return r
358 }
359
360 var colorin = "#00f"
361 var colorout = "#f00"

Callers 1

EdgeBundlingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected