hasse {paircompviz} | R Documentation |
Given an adjacency matrix, this function displays the corresponding Hasse diagram. This is a wrapper function for graph creation using the Rgraphviz package.
hasse(e, v=NULL, elab="", ecol="black", ebg="gray", vcol="black", vbg="white", vsize=1, fvlab=".", fvcol="black", fvbg="white", fvsize=1, febg="black", fesize=1, main=paste("Hasse Diagram of", deparse(substitute(e))), compress=FALSE)
e |
An adjacency matrix, with e_{i,j} indicating the edge size between vertices i and j (e_{i,j} = 0 means no edge between i and j). The matrix must be rectangular with non-negative non-missing values. |
v |
Vector of names of the vertices. If null, the vertex names will be obtained from column names of adjacency matrix e. |
elab |
Labels of the edges. If it is a scalar value, all edges would have the same label. Otherwise, elab must be a rectangular matrix (similar to adjacency matrix e). A value on i-th row and j-th column is a label of the edge between vertex i and vertex j. |
ecol |
Edge label color. If scalar, all edge labels have the same color. Otherwise, ecol must be in the form of adjacency matrix: a value on i-th row and j-th column is a color of the label of the edge between vertex i and vertex j. |
ebg |
Edge line color. If scalar, all edges have the same color. Otherwise, ebg must be in the form of adjacency matrix: a value on i-th row and j-th column is a color of the edge between vertex i and vertex j. |
vcol |
Vertex label color. If scalar, all vertices have the same label color. Otherwise, vcol must be a vector of the size corresponding to the number of vertices. |
vbg |
Vertex background color. If scalar, all vertices have the same background color. Otherwise, vcol must be a vector of the size corresponding to the number of vertices. |
vsize |
Vertex sizes. If scalar, all vertices have the same size in the image. Otherwise, vsize must be a vector of the size corresponding to the number of vertices. |
fvlab |
Labels of "dot" vertices. Must be scalar. |
fvcol |
"dot" vertex label color. Must be scalar. |
fvbg |
"dot" vertex background color. Must be scalar. |
fvsize |
"dot" vertex size. Must be scalar. |
febg |
Color of edges introduced by edge compression. Must be scalar. |
fesize |
Thickness of edges introduced by edge compression. Must be scalar and non-negative. |
main |
Main title of the diagram. |
compress |
|
This function depicts a Hasse diagram specified with an adjacency matrix e. Hasse diagram is a visualization of partially ordered set, by drawing its transitive reduction as an oriented graph. Each vertex corresponds to an element of the set. There is an edge between vertex i and vertex j iff i < j and there is no z such that i < z < j.
The function is also capable of edge compression via introducing the "dot" edges:
Let U, V be two disjoint non-empty sets of edges,
such that for each u from U and v from V, there exists an edge
from u to v. (The number of such edges equals |U| \cdot |V|.) Starting from
|U| > 2 and |V| > 2, the Hasse diagram may become too complicated and hence confusing.
Therefore a compress
argument exists in this function that enables “compression” of
the edges in such a way that a new “dot” node w is introduced and |U| \cdot |V|
edges between sets U and V are replaced with |U|+|V| edges from set U
to node w and from node w to set V.
Nothing.
Michal Burda
# linear order e <- matrix(c(0, 1, 1, 0, 0, 1, 0, 0, 0), nrow=3, byrow=TRUE) hasse(e) # prepare adjacency matrix m <- matrix(0, byrow=TRUE, nrow=5, ncol=5) m[3, 1] <- 1 m[3, 2] <- 1 m[4, 1] <- 9 m[4, 2] <- 1 m[5, 1] <- 1 m[5, 2] <- 1 m mc <- m mc[mc > 0] <- "red" ms <- m ms[ms > 0] <- "blue" # view m with default settings hasse(m, ebg="black") # view m WITHOUT edge compression and some fancy adjustments hasse(v=c("a", "b", "c", "d", "e"), vcol=c(gray(0.5), gray(1), rep(gray(0), 3)), vbg=gray(5:1/5), vsize=1:5, e=m, ecol=mc, ebg=ms, elab=m, compress=FALSE) # view m WITH edge compression and some fancy adjustments hasse(v=c("a", "b", "c", "d", "e"), vcol=c(gray(0.5), gray(1), rep(gray(0), 3)), vbg=gray(5:1/5), vsize=1:5, e=m, ecol=mc, ebg=ms, elab=m, compress=TRUE)