MCPcopy
hub / github.com/mrpandey/d3graphTheory / restart

Function restart

ch/graphic-sequence/app.js:250–316  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

248//updates the graph by updating links, nodes and binding them with DOM
249//interface is defined through several events
250function restart() {
251 edges = edges.data(links, function(d) {
252 return "v" + d.source.id + "-v" + d.target.id;
253 });
254 edges.exit().remove();
255
256 var ed = edges
257 .enter()
258 .append("line")
259 .attr("class", "edge")
260 .on("mousedown", function() {
261 d3.event.stopPropagation();
262 })
263 .on("contextmenu", removeEdge);
264
265 ed.append("title").text(function(d) {
266 return "v" + d.source.id + "-v" + d.target.id;
267 });
268
269 edges = ed.merge(edges);
270
271 //vertices are known by id
272 vertices = vertices.data(nodes, function(d) {
273 return d.id;
274 });
275 vertices.exit().remove();
276
277 vertices.selectAll("text").text(function(d) {
278 return d.degree;
279 });
280
281 var g = vertices
282 .enter()
283 .append("g")
284 .attr("class", "vertex")
285 //so that force.drag and addNode don't interfere
286 //mousedown is initiated on circle which is stopped at .vertex
287 .on("mousedown", function() {
288 d3.event.stopPropagation();
289 });
290
291 g.append("circle")
292 .attr("r", rad)
293 .style("fill", function(d, i) {
294 return colors[d.id % 10];
295 })
296 .on("mousedown", beginDragLine)
297 .on("mouseup", endDragLine)
298 .on("contextmenu", removeNode)
299 .append("title")
300 .text(function(d) {
301 return "v" + d.id;
302 });
303
304 g.append("text")
305 .attr("x", 0)
306 .attr("y", 4)
307 .text(function(d) {

Callers 7

clearGraphFunction · 0.70
addNodeFunction · 0.70
removeNodeFunction · 0.70
removeEdgeFunction · 0.70
hideDragLineFunction · 0.70
app.jsFile · 0.70
setGraphFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected