1
- (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
1
+ (function () { var define = undefined; (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
2
!function() {
3
3
var d3 = {
4
4
version: "3.4.13"
@@ -9252,7 +9252,8 @@ var util = require("./util");
9252
9252
module.exports = {
9253
9253
"default": normal,
9254
9254
"normal": normal,
9255
- "vee": vee
9255
+ "vee": vee,
9256
+ "undirected": undirected
9256
9257
};
9257
9258
9258
9259
function normal(parent, id, edge, type) {
@@ -9291,6 +9292,24 @@ function vee(parent, id, edge, type) {
9291
9292
util.applyStyle(path, edge[type + "Style"]);
9292
9293
}
9293
9294
9295
+ function undirected(parent, id, edge, type) {
9296
+ var marker = parent.append("marker")
9297
+ .attr("id", id)
9298
+ .attr("viewBox", "0 0 10 10")
9299
+ .attr("refX", 9)
9300
+ .attr("refY", 5)
9301
+ .attr("markerUnits", "strokeWidth")
9302
+ .attr("markerWidth", 8)
9303
+ .attr("markerHeight", 6)
9304
+ .attr("orient", "auto");
9305
+
9306
+ var path = marker.append("path")
9307
+ .attr("d", "M 0 5 L 10 5")
9308
+ .style("stroke-width", 1)
9309
+ .style("stroke-dasharray", "1,0");
9310
+ util.applyStyle(path, edge[type + "Style"]);
9311
+ }
9312
+
9294
9313
},{"./util":26}],4:[function(require,module,exports){
9295
9314
var util = require("./util");
9296
9315
@@ -9384,6 +9403,15 @@ function createEdgePaths(selection, g, arrows) {
9384
9403
util.applyTransition(svgPaths, g)
9385
9404
.style("opacity", 1);
9386
9405
9406
+ // Save DOM element in the path group, and set ID
9407
+ svgPaths.each(function(e) {
9408
+ var edge = g.edge(e);
9409
+ edge.elem = this;
9410
+ if (edge.id) {
9411
+ d3.select(this).attr("id", edge.id);
9412
+ }
9413
+ });
9414
+
9387
9415
svgPaths.selectAll("path.path")
9388
9416
.each(function(e) {
9389
9417
var edge = g.edge(e);
@@ -9398,7 +9426,6 @@ function createEdgePaths(selection, g, arrows) {
9398
9426
util.applyTransition(domEdge, g)
9399
9427
.attr("d", function(e) { return calcPoints(g, e); });
9400
9428
9401
- if (edge.id) { domEdge.attr("id", edge.id); }
9402
9429
util.applyStyle(domEdge, edge.style);
9403
9430
});
9404
9431
@@ -9515,7 +9542,8 @@ function createNodes(selection, g, shapes) {
9515
9542
9516
9543
if (node.id) { thisGroup.attr("id", node.id); }
9517
9544
if (node.labelId) { labelGroup.attr("id", node.labelId); }
9518
- util.applyClass(thisGroup, node.class, (thisGroup.classed("update") ? "update " : "") + "node");
9545
+ util.applyClass(thisGroup, node["class"],
9546
+ (thisGroup.classed("update") ? "update " : "") + "node");
9519
9547
9520
9548
if (_.has(node, "width")) { bbox.width = node.width; }
9521
9549
if (_.has(node, "height")) { bbox.height = node.height; }
@@ -10146,12 +10174,14 @@ function createOrSelectGroup(root, name) {
10146
10174
10147
10175
var intersectRect = require("./intersect/intersect-rect"),
10148
10176
intersectEllipse = require("./intersect/intersect-ellipse"),
10149
- intersectCircle = require("./intersect/intersect-circle");
10177
+ intersectCircle = require("./intersect/intersect-circle"),
10178
+ intersectPolygon = require("./intersect/intersect-polygon");
10150
10179
10151
10180
module.exports = {
10152
10181
rect: rect,
10153
10182
ellipse: ellipse,
10154
- circle: circle
10183
+ circle: circle,
10184
+ diamond: diamond
10155
10185
};
10156
10186
10157
10187
function rect(parent, bbox, node) {
@@ -10200,7 +10230,29 @@ function circle(parent, bbox, node) {
10200
10230
return shapeSvg;
10201
10231
}
10202
10232
10203
- },{"./intersect/intersect-circle":12,"./intersect/intersect-ellipse":13,"./intersect/intersect-rect":17}],26:[function(require,module,exports){
10233
+ // Circumscribe an ellipse for the bounding box with a diamond shape. I derived
10234
+ // the function to calculate the diamond shape from:
10235
+ // http://mathforum.org/kb/message.jspa?messageID=3750236
10236
+ function diamond(parent, bbox, node) {
10237
+ var w = (bbox.width * Math.SQRT2) / 2,
10238
+ h = (bbox.height * Math.SQRT2) / 2,
10239
+ points = [
10240
+ { x: 0, y: -h },
10241
+ { x: -w, y: 0 },
10242
+ { x: 0, y: h },
10243
+ { x: w, y: 0 }
10244
+ ],
10245
+ shapeSvg = parent.insert("polygon", ":first-child")
10246
+ .attr("points", points.map(function(p) { return p.x + "," + p.y; }).join(" "));
10247
+
10248
+ node.intersect = function(p) {
10249
+ return intersectPolygon(node, points, p);
10250
+ };
10251
+
10252
+ return shapeSvg;
10253
+ }
10254
+
10255
+ },{"./intersect/intersect-circle":12,"./intersect/intersect-ellipse":13,"./intersect/intersect-polygon":16,"./intersect/intersect-rect":17}],26:[function(require,module,exports){
10204
10256
var _ = require("./lodash");
10205
10257
10206
10258
// Public utility functions
@@ -10257,7 +10309,7 @@ function applyTransition(selection, g) {
10257
10309
}
10258
10310
10259
10311
},{"./lodash":21}],27:[function(require,module,exports){
10260
- module.exports = "0.3.3 ";
10312
+ module.exports = "0.4.2 ";
10261
10313
10262
10314
},{}],28:[function(require,module,exports){
10263
10315
/*
@@ -10644,7 +10696,7 @@ function removeNode(g, buckets, zeroIdx, entry, collectPredecessors) {
10644
10696
var weight = g.edge(edge),
10645
10697
w = edge.w,
10646
10698
wEntry = g.node(w);
10647
- wEntry.in -= weight;
10699
+ wEntry["in"] -= weight;
10648
10700
assignBucket(buckets, zeroIdx, wEntry);
10649
10701
});
10650
10702
@@ -10659,7 +10711,7 @@ function buildState(g, weightFn) {
10659
10711
maxOut = 0;
10660
10712
10661
10713
_.each(g.nodes(), function(v) {
10662
- fasGraph.setNode(v, { v: v, in : 0, out: 0 });
10714
+ fasGraph.setNode(v, { v: v, "in" : 0, out: 0 });
10663
10715
});
10664
10716
10665
10717
// Aggregate weights on nodes, but also sum the weights across multi-edges
@@ -10670,7 +10722,7 @@ function buildState(g, weightFn) {
10670
10722
edgeWeight = prevWeight + weight;
10671
10723
fasGraph.setEdge(e.v, e.w, edgeWeight);
10672
10724
maxOut = Math.max(maxOut, fasGraph.node(e.v).out += weight);
10673
- maxIn = Math.max(maxIn, fasGraph.node(e.w).in += weight);
10725
+ maxIn = Math.max(maxIn, fasGraph.node(e.w)["in"] += weight);
10674
10726
});
10675
10727
10676
10728
var buckets = _.range(maxOut + maxIn + 3).map(function() { return new List(); });
@@ -10686,10 +10738,10 @@ function buildState(g, weightFn) {
10686
10738
function assignBucket(buckets, zeroIdx, entry) {
10687
10739
if (!entry.out) {
10688
10740
buckets[0].enqueue(entry);
10689
- } else if (!entry.in ) {
10741
+ } else if (!entry["in"] ) {
10690
10742
buckets[buckets.length - 1].enqueue(entry);
10691
10743
} else {
10692
- buckets[entry.out - entry.in + zeroIdx].enqueue(entry);
10744
+ buckets[entry.out - entry["in"] + zeroIdx].enqueue(entry);
10693
10745
}
10694
10746
}
10695
10747
@@ -11705,7 +11757,7 @@ function resolveConflicts(entries, cg) {
11705
11757
_.each(entries, function(entry, i) {
11706
11758
var tmp = mappedEntries[entry.v] = {
11707
11759
indegree: 0,
11708
- in : [],
11760
+ "in" : [],
11709
11761
out: [],
11710
11762
vs: [entry.v],
11711
11763
i: i
@@ -11750,7 +11802,7 @@ function doResolveConflicts(sourceSet) {
11750
11802
11751
11803
function handleOut(vEntry) {
11752
11804
return function(wEntry) {
11753
- wEntry.in .push(vEntry);
11805
+ wEntry["in"] .push(vEntry);
11754
11806
if (--wEntry.indegree === 0) {
11755
11807
sourceSet.push(wEntry);
11756
11808
}
@@ -11760,7 +11812,7 @@ function doResolveConflicts(sourceSet) {
11760
11812
while (sourceSet.length) {
11761
11813
var entry = sourceSet.pop();
11762
11814
entries.push(entry);
11763
- _.each(entry.in .reverse(), handleIn(entry));
11815
+ _.each(entry["in"] .reverse(), handleIn(entry));
11764
11816
_.each(entry.out, handleOut(entry));
11765
11817
}
11766
11818
@@ -12022,6 +12074,7 @@ function postorder(g) {
12022
12074
"use strict";
12023
12075
12024
12076
var _ = require("../lodash"),
12077
+ Graph = require("../graphlib").Graph,
12025
12078
util = require("../util");
12026
12079
12027
12080
/*
@@ -12225,74 +12278,71 @@ function verticalAlignment(g, layering, conflicts, neighborFn) {
12225
12278
}
12226
12279
12227
12280
function horizontalCompaction(g, layering, root, align, reverseSep) {
12228
- // We use local variables for these parameters instead of manipulating the
12229
- // graph because it becomes more verbose to access them in a chained manner.
12230
- var shift = {},
12231
- shiftNeighbor = {},
12232
- sink = {},
12233
- xs = {},
12234
- pred = {},
12235
- graphLabel = g.graph(),
12236
- sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep);
12237
-
12238
- _.each(layering, function(layer) {
12239
- _.each(layer, function(v, order) {
12240
- sink[v] = v;
12241
- shift[v] = Number.POSITIVE_INFINITY;
12242
- pred[v] = layer[order - 1];
12243
- });
12244
- });
12281
+ // This portion of the algorithm differs from BK due to a number of problems.
12282
+ // Instead of their algorithm we construct a new block graph and do two
12283
+ // sweeps. The first sweep places blocks with the smallest possible
12284
+ // coordinates. The second sweep removes unused space by moving blocks to the
12285
+ // greatest coordinates without violating separation.
12286
+ var xs = {},
12287
+ blockG = buildBlockGraph(g, layering, root, reverseSep);
12288
+
12289
+ // First pass, assign smallest coordinates via DFS
12290
+ var visited = {};
12291
+ function pass1(v) {
12292
+ if (!_.has(visited, v)) {
12293
+ visited[v] = true;
12294
+ xs[v] = _.reduce(blockG.inEdges(v), function(max, e) {
12295
+ pass1(e.v);
12296
+ return Math.max(max, xs[e.v] + blockG.edge(e));
12297
+ }, 0);
12298
+ }
12299
+ }
12300
+ _.each(blockG.nodes(), pass1);
12245
12301
12246
- _.each(g.nodes(), function(v) {
12247
- if (root[v] === v) {
12248
- placeBlock(g, layering, sepFn, root, align, shift, shiftNeighbor, sink, pred, xs, v);
12302
+ function pass2(v) {
12303
+ if (visited[v] !== 2) {
12304
+ visited[v]++;
12305
+ var min = _.reduce(blockG.outEdges(v), function(min, e) {
12306
+ pass2(e.w);
12307
+ return Math.min(min, xs[e.w] - blockG.edge(e));
12308
+ }, Number.POSITIVE_INFINITY);
12309
+ if (min !== Number.POSITIVE_INFINITY) {
12310
+ xs[v] = Math.max(xs[v], min);
12311
+ }
12249
12312
}
12250
- });
12313
+ }
12314
+ _.each(blockG.nodes(), pass2);
12251
12315
12252
- _.each(layering, function(layer) {
12253
- _.each(layer, function(v) {
12254
- xs[v] = xs[root[v]];
12255
- // This line differs from the source paper. See
12256
- // http://www.inf.uni-konstanz.de/~brandes/publications/ for details.
12257
- if (v === root[v] && shift[sink[root[v]]] < Number.POSITIVE_INFINITY) {
12258
- xs[v] += shift[sink[root[v]]];
12259
12316
12260
- // Cascade shifts as necessary
12261
- var w = shiftNeighbor[sink[root[v]]];
12262
- if (w && shift[w] !== Number.POSITIVE_INFINITY) {
12263
- xs[v] += shift[w];
12264
- }
12265
- }
12266
- });
12317
+ // Assign x coordinates to all nodes
12318
+ _.each(align, function(v) {
12319
+ xs[v] = xs[root[v]];
12267
12320
});
12268
12321
12269
12322
return xs;
12270
12323
}
12271
12324
12272
- function placeBlock(g, layering, sepFn, root, align, shift, shiftNeighbor, sink, pred, xs, v) {
12273
- if (_.has(xs, v)) return;
12274
- xs[v] = 0;
12275
12325
12276
- var w = v,
12277
- u;
12278
- do {
12279
- if (pred[w]) {
12280
- u = root[pred[w]];
12281
- placeBlock(g, layering, sepFn, root, align, shift, shiftNeighbor, sink, pred, xs, u);
12282
- if (sink[v] === v) {
12283
- sink[v] = sink[u];
12284
- }
12326
+ function buildBlockGraph(g, layering, root, reverseSep) {
12327
+ var blockGraph = new Graph(),
12328
+ graphLabel = g.graph(),
12329
+ sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep);
12285
12330
12286
- var delta = sepFn(g, w, pred[w]);
12287
- if (sink[v] !== sink[u]) {
12288
- shift[sink[u]] = Math.min(shift[sink[u]], xs[v] - xs[u] - delta);
12289
- shiftNeighbor[sink[u]] = sink[v];
12290
- } else {
12291
- xs[v] = Math.max(xs[v], xs[u] + delta);
12292
- }
12293
- }
12294
- w = align[w];
12295
- } while (w !== v);
12331
+ _.each(layering, function(layer) {
12332
+ var u;
12333
+ _.each(layer, function(v) {
12334
+ var vRoot = root[v];
12335
+ blockGraph.setNode(vRoot);
12336
+ if (u) {
12337
+ var uRoot = root[u],
12338
+ prevMax = blockGraph.edge(uRoot, vRoot);
12339
+ blockGraph.setEdge(uRoot, vRoot, Math.max(sepFn(g, v, u), prevMax || 0));
12340
+ }
12341
+ u = v;
12342
+ });
12343
+ });
12344
+
12345
+ return blockGraph;
12296
12346
}
12297
12347
12298
12348
/*
@@ -12419,7 +12469,7 @@ function width(g, v) {
12419
12469
return g.node(v).width;
12420
12470
}
12421
12471
12422
- },{"../lodash":37,"../util":56}],51:[function(require,module,exports){
12472
+ },{"../graphlib":34,"../ lodash":37,"../util":56}],51:[function(require,module,exports){
12423
12473
"use strict";
12424
12474
12425
12475
var _ = require("../lodash"),
@@ -13130,7 +13180,7 @@ function notime(name, fn) {
13130
13180
}
13131
13181
13132
13182
},{"./graphlib":34,"./lodash":37}],57:[function(require,module,exports){
13133
- module.exports = "0.6.4 ";
13183
+ module.exports = "0.7.1 ";
13134
13184
13135
13185
},{}],58:[function(require,module,exports){
13136
13186
/**
@@ -24757,7 +24807,7 @@ module.exports={
24757
24807
"dependencies": {
24758
24808
"chalk": "^0.5.1",
24759
24809
"d3": "~3.4.13",
24760
- "dagre-d3": "~0.3.3 ",
24810
+ "dagre-d3": "~0.4.2 ",
24761
24811
"he": "^0.5.0",
24762
24812
"minimist": "^1.1.0",
24763
24813
"mkdirp": "^0.5.0",
@@ -24782,6 +24832,7 @@ module.exports={
24782
24832
"gulp-data": "^1.1.1",
24783
24833
"gulp-ext-replace": "~0.1.0",
24784
24834
"gulp-hogan": "^1.1.0",
24835
+ "gulp-insert": "^0.4.0",
24785
24836
"gulp-istanbul": "^0.4.0",
24786
24837
"gulp-jasmine": "~1.0.1",
24787
24838
"gulp-jison": "~1.0.0",
@@ -31017,4 +31068,4 @@ module.exports.cloneCssStyles = function(svg, classes){
31017
31068
}
31018
31069
};
31019
31070
31020
- },{}]},{},[102])
31071
+ },{}]},{},[102]) })();
0 commit comments