Hyperdraw: bidirectional edges
1
0
Entering edit mode
hettling ▴ 60
@hettling-5170
Last seen 9.6 years ago
Hello, I have another question about the Hyperdraw package. I would like to draw bidirectional edges with arrows on both sides of the edge. I took the example from the vignette, below my failed naive attempt: ## dh1 <- DirectedHyperedge("A", "B", "R1") dh1r <- DirectedHyperedge("B", "A", "R1") ##added edge dh2 <- DirectedHyperedge(c("A", "B"), c("C", "D"), "R2") dh3 <- DirectedHyperedge("D", "E", "R3") hg <- Hypergraph(LETTERS[1:5], list(dh1, dh1r, dh2, dh3)) testbph <- graphBPH(hg) testrabph <- graphLayout(testbph, layoutType="dot") graphDataDefaults(testrabph, "arrowLoc") <- "end" plot(testrabph) ## In order to make the edge from "A" -> "B" bidirectional, I made another edge "B" -> "A" with the same label. Now I get two distinct edges. Is there a way to get two arrows on one and the same edge? Also, I do not understand why in my example, the edge labels are the numbers 1:4, despite the fact that all 'DirectedHyperedge' objects have a label. I hope my question is clear, many thanks in advance. With Kind Regards Hannes
hyperdraw hyperdraw • 1.2k views
ADD COMMENT
0
Entering edit mode
Paul Murrell ▴ 30
@paul-murrell-5669
Last seen 9.5 years ago
New Zealand
Hi I have committed two changes to 'hyperdraw': 1. You can now specify "start" and "both" as a value for "arrowLoc" to get arrows at start as well as end of hyperedge. 2. The conversion from Hypergraph to graphBPH now properly uses the HyperEdge labels. With those changes, the following should work ... dh1 <- DirectedHyperedge("A", "B", "R1") dh2 <- DirectedHyperedge(c("A", "B"), c("C", "D"), "R2") dh3 <- DirectedHyperedge("D", "E", "R3") hg <- Hypergraph(LETTERS[1:5], list(dh1, dh2, dh3)) testbph <- graphBPH(hg) testrabph <- graphLayout(testbph, layoutType="dot") graphDataDefaults(testrabph, "arrowLoc") <- "both" plot(testrabph) A workaround with the currently released version of 'hyperdraw' is this ... dh1 <- DirectedHyperedge("A", "B", "R1") dh2 <- DirectedHyperedge(c("A", "B"), c("C", "D"), "R2") dh3 <- DirectedHyperedge("D", "E", "R3") hg <- Hypergraph(LETTERS[1:5], list(dh1, dh2, dh3)) testbph <- graphBPH(hg) testrabph <- graphLayout(testbph, layoutType="dot") graphDataDefaults(testrabph, "arrowLoc") <- "end" plot(testrabph) edges <- grid.get("xspline", grep=TRUE, global=TRUE) for (i in edges) { if (is.null(i$arrow)) { grid.edit(i$name, arrow=arrow(angle=30, length=unit(1.5, "mm"), ends="first", type="closed"), redraw=FALSE) } } edgeNames <- hyperedgeLabels(hg) edgeLabels <- grid.get("text", grep=TRUE, global=TRUE) for (i in 1:length(edgeLabels)) { grid.edit(edgeLabels[[i]]$name, label=edgeNames[i], redraw=FALSE) } grid.refresh() Does that do what you want ? Paul On 05/14/13 03:27, hettling wrote: > Hello, > > I have another question about the Hyperdraw package. I would like to > draw bidirectional edges with arrows on both sides of the edge. > > I took the example from the vignette, below my failed naive attempt: > > ## > dh1 <- DirectedHyperedge("A", "B", "R1") > dh1r <- DirectedHyperedge("B", "A", "R1") ##added edge > dh2 <- DirectedHyperedge(c("A", "B"), c("C", "D"), "R2") > dh3 <- DirectedHyperedge("D", "E", "R3") > hg <- Hypergraph(LETTERS[1:5], list(dh1, dh1r, dh2, dh3)) > testbph <- graphBPH(hg) > testrabph <- graphLayout(testbph, layoutType="dot") > graphDataDefaults(testrabph, "arrowLoc") <- "end" > plot(testrabph) > ## > > In order to make the edge from "A" -> "B" bidirectional, I made another > edge "B" -> "A" with the same label. Now I get two distinct edges. > > Is there a way to get two arrows on one and the same edge? > > Also, I do not understand why in my example, the edge labels are the > numbers 1:4, despite the fact that all 'DirectedHyperedge' objects have > a label. > > I hope my question is clear, > many thanks in advance. > > With Kind Regards > > Hannes > > -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/
ADD COMMENT

Login before adding your answer.

Traffic: 1087 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6