Skip to content

Commit

Permalink
Drawing undirected graphs
Browse files Browse the repository at this point in the history
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'});
  • Loading branch information
DavidPratten committed Jan 3, 2015
1 parent e7a3ac7 commit 85d0f07
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/arrows.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var util = require("./util");
module.exports = {
"default": normal,
"normal": normal,
"vee": vee
"vee": vee,
"undirected": undirected
};

function normal(parent, id, edge, type) {
Expand Down Expand Up @@ -41,3 +42,21 @@ function vee(parent, id, edge, type) {
.style("stroke-dasharray", "1,0");
util.applyStyle(path, edge[type + "Style"]);
}

function undirected(parent, id, edge, type) {
var marker = parent.append("marker")
.attr("id", id)
.attr("viewBox", "0 0 10 10")
.attr("refX", 9)
.attr("refY", 5)
.attr("markerUnits", "strokeWidth")
.attr("markerWidth", 8)
.attr("markerHeight", 6)
.attr("orient", "auto");

var path = marker.append("path")
.attr("d", "M 0 5 L 10 5")
.style("stroke-width", 1)
.style("stroke-dasharray", "1,0");
util.applyStyle(path, edge[type + "Style"]);
}

0 comments on commit 85d0f07

Please sign in to comment.