Description Usage Arguments Value Author(s) References See Also Examples
These functions provide some support for working with graphs in SVG generated via Rgraphviz.
addGraphIds
takes the graph layout (Ragraph-class
)
object and determines the SVG elements corresponding to the nodes and edges
and places id and class attributes on each. This allows us to easily identify
the elements in subsequent computations, both in R and JavaScript.
A single node in the graph typically has two SVG elements associated with it: the circle and the text/label. We treat the circle as the node. The ids for the node circles are taken as the names from the graph layout object. The ids for the node labels are the same names but with "-label" appended.
The id for an edge is slightly more complex. The general format is "edge:tail-head", where tail and head are the names of the relevant nodes. For undirected edges, the order is important. The head is the earlier node in the list of node names. (We haven't dealt with directed edges yet.)
The edges have class "edge" and the nodes "node" and the text of the node "nodeLabel"
getNodeElements
and getEdgeElements
can be used
to get the SVG elements in the document that correspond to the
nodes and edges using the class attribute added by addGraphIds
.
These functions will not work correctly before addGraphIds
has been called.
getEdgeInfo
is used by addGraphIds
and by users annotating SVG documents in R
to get the edge identifiers (i.e. the id attributes) in the correct form.
Unlike the other functions, this does not work with the SVG document, but with the graph object directly.
There are methods for a graphNEL
object and a laid-out Ragraph
These functions are not necessarily complete (!) and will not necessarily work for different types of graph layouts. The basic ideas however should extend readily to these other types but have not been implemented yet. Currently, the functions will typically only work correctly when each edge corresponds to just one SVG element. This is the case for the twopi layout.
1 2 3 4 5 6 7 | addGraphIds(doc, graph,
main = getNodeSet(doc,
"//s:svg/s:g/s:g",
c("s"= "http://www.w3.org/2000/svg"))[[1]])
getNodeElements(doc)
getEdgeElements(doc)
getEdgeInfo(graph, ...)
|
doc |
the parsed XML/SVG document |
graph |
the graph object. For |
main |
the XML element in the SVG document which contains (as children) the elements for the nodes and edges in our graph |
... |
extra parameters for methods to specialize |
getNodeElements
returns a list of XMLInternalNode
objects corresponding to the nodes of the graph in the SVG display.
Similarly, getEdgeElements
returns a list of
XMLInternalNode
objects corresponding to the edges in the
graph.
addGraphIds
returns a list with three elements
edgeIdsa character vector giving the values of the id
attributes for the SVG elements corresponding to the graph's
edges.
edgeLabelsa character vector giving the text labels for the edges.
nodeIdsa character vector giving the values of the id
attributes for the SVG elements corresponding to the graph's nodes.
getEdgeInfo
returns a list with as manay elements
as there are edges. Each element is a character vector giving the
"edge:src-dest" label identifying the connections..
Duncan Temple Lang
graph and Rgraphviz packages. BioConductor book "Bioinformatics and Computational Biology Solutions Using R and BioConductor". Gentleman, Carey, Huber, Irizarry and Dudoit (Editors). 2005.
1 | # See the example in the tests/ directory of the package.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.