exec(generateGraphCommand, function(error, stdout, stderr) { if(error) return cb(error); if(stderr) return db(error); var dotGraphStr = stdout; var g = dot.read(dotGraphStr); var codeChange = g.nodes()[0]; var contributor = g.node(codeChange).contributor var time = parseInt(g.node(codeChange).time); var mongooseDoc = { dot: dotGraphStr, contributor: contributor, time: time }; //var mongooseDocStr = JSON.stringify(mongooseDoc); cb(null, mongooseDoc); });
objectGraphStream.on('data', function({vertices, edges, builtins, root}) { const output = ['digraph {'] let ID = 1; const mapping = new Map() for (const vertex of vertices) { const id = ID++ mapping.set(vertex, id) output.push(id + ` [label=${ JSON.stringify( vertex.stack || vertex.toparent ? 'Stack Item' : vertex.root ? 'Root' : vertex.classInfo ? vertex.classInfo() : vertex.getName ? 'name: ' + vertex.getName() : '???' ) }]`) } for (const edge of edges) { if (!mapping.get(edge[0]) || !mapping.get(edge[1])) { continue } output.push(`${mapping.get(edge[0])} -> ${mapping.get(edge[1])} [label=${ JSON.stringify(edge[2]) }]`) } output.push('}') const results = graphlibDot.read(output.join('\n')) if (!results.graph().hasOwnProperty('marginx') && !results.graph().hasOwnProperty('marginy')) { results.graph().marginx = 20 results.graph().marginy = 20 } results.graph().transition = function(selection) { return selection.transition().duration(500) } objectGraph.call(renderObject, results) })
analyze.createCFG(code, function(err, cfg) { if (err) { document.body.classList.add('play-disabled') disabled = true return } disabled = false document.body.classList.remove('play-disabled') lastGoodCode = code const results = graphlibDot.read(cfg.toDot()) if (!results.graph().hasOwnProperty('marginx') && !results.graph().hasOwnProperty('marginy')) { results.graph().marginx = 20 results.graph().marginy = 20 } results.graph().transition = function(selection) { return selection.transition().duration(500) } flowGraph.call(renderFlow, results) })