Skip to content

Commit 85d0f07

Browse files
committed
Drawing undirected graphs
This change facilitates the drawing of undirected graphs. Note this is a visual change only. The underlying graph remains a directed graph. Usage: g.setEdge(x, y, {arrowhead: 'undirected'});
1 parent e7a3ac7 commit 85d0f07

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

lib/arrows.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ var util = require("./util");
33
module.exports = {
44
"default": normal,
55
"normal": normal,
6-
"vee": vee
6+
"vee": vee,
7+
"undirected": undirected
78
};
89

910
function normal(parent, id, edge, type) {
@@ -41,3 +42,21 @@ function vee(parent, id, edge, type) {
4142
.style("stroke-dasharray", "1,0");
4243
util.applyStyle(path, edge[type + "Style"]);
4344
}
45+
46+
function undirected(parent, id, edge, type) {
47+
var marker = parent.append("marker")
48+
.attr("id", id)
49+
.attr("viewBox", "0 0 10 10")
50+
.attr("refX", 9)
51+
.attr("refY", 5)
52+
.attr("markerUnits", "strokeWidth")
53+
.attr("markerWidth", 8)
54+
.attr("markerHeight", 6)
55+
.attr("orient", "auto");
56+
57+
var path = marker.append("path")
58+
.attr("d", "M 0 5 L 10 5")
59+
.style("stroke-width", 1)
60+
.style("stroke-dasharray", "1,0");
61+
util.applyStyle(path, edge[type + "Style"]);
62+
}

0 commit comments

Comments
 (0)