Skip to content

Instantly share code, notes, and snippets.

@jackbergus
Last active August 29, 2015 13:55
Show Gist options
  • Save jackbergus/8785189 to your computer and use it in GitHub Desktop.
Save jackbergus/8785189 to your computer and use it in GitHub Desktop.
# Giacomo Bergami (c) 2014
# This gists is licensed under GPL-2 | GPL-3
library(hyperdraw)
library(hypergraph)
#vertices <- c("id1","id2","id3","id4","tom","sam","pos1","pos2","helloworld","ciaomondo","hashtag","geotag1","geotag2")
#dh1 <- DirectedHyperedge(c("tom","pos1"),c("id1"),"User<:ED")
#dh2 <- DirectedHyperedge(c("sam","pos2"),c("id2"),"User<:ED")
#h <- Hypergraph(vertices,list(dh1,dh2))
#tp <- graphBPH(h)
#plot(tp)
setProp <- function(gl,dh1,param,val) {
for (x in dh1@head) {
for (y in dh1@tail) {
edgeData(gl,c(x,dh1@label),c(dh1@label,y),param) <- val
}
}
}
vertices <- c("A","B","C","D","E")
dh1 <- DirectedHyperedge("A",c("B","C"),"R1")
dh2 <- DirectedHyperedge(c("A","E"),c("D","B","C"),"R2")
hg <- Hypergraph(vertices,list(dh1,dh2))
gl <- graphLayout(graphBPH(hg))
setProp(gl,dh1,"color","blue")
setProp(gl,dh2,"color","red")
plot(gl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment