Entering edit mode
Hi All,
I'm trying to generate a graph layout where I already have the
positions of the nodes, but essentially I want Rgraphviz to figure out
how the edges should appear. I guess the first question would be does
Rgraphviz support the position attribute?
Here is what I have tried so far to see if using the 'pos' attribute
even works:
# get the graph
set.seed(123)
V <- letters[1:5]
M <- 1:3
g1 <- randomGraph(V, M, .2)
# and here is the default
z <- agopen(g1, "foo")
plot(z)
# now try to modify the positions
nodeNames <- nodes(g1)
nNodes <- length(nodeNames)
nodePos <- vector("character", nNodes)
names(nodePos) <- nodeNames
nodePos[1:nNodes] <-
c(".15,.15",".25,.25",".35,.35",".45,.45",".55,.55")
# note I have tried the above with "x,y!", and have also tried using
tens and hundreds values
nodeAttrs <- list(pos=nodePos)
# using "dot" as the layout engine, the '!' above is supposed to keep
it from changing the node position, see:
http://www.graphviz.org/pub/scm/graphviz2/doc/info/attrs.html#a:pos
z <- agopen(g1,name="foo",nodeAttrs=nodeAttrs)
plot(z)
# try using Pin in Neato
nodePin <- character(nNodes)
names(nodePin) <- nodeNames
nodePin[1:nNodes] <- "TRUE"
nodeAttrs <- list(pos=nodePos, pin=nodePin)
z <- agopen(g1,name="foo",nodeAttrs=nodeAttrs,layoutType="neato")
plot(z)
I also checked the slot AgNodes to verify if it was just getting
changed when calling plot, but the positions are not what I would
expect if the nodes were laid out in a straight line.
Any suggestions? Is at all what I am trying to do even possible?
Thanks in advance.
-Robert
Robert M. Flight, Ph.D.
Bioinformatics and Biomedical Computing Laboratory
University of Louisville
Louisville, KY
PH 502-852-0467
EM robert.flight at louisville.edu
EM rflight79 at gmail.com
Williams and Holland's Law:
? ? ?? If enough data is collected, anything may be proven by
statistical methods.