如何在 rgraphviz 中找到节点的等级?

How do I find the rank of a node in rgraphviz?

我在 rgraphviz 中有一个有向无环图,它将被渲染为一个点图。我想根据等级控制节点的外观。如何找到节点的等级?

这是我的答案。欢迎提出建议。

gR 是正式 class GRAPHNEL

的对象
gx <- layoutGraph(gR) #can also add node attributes, sublists here
x <- gx@renderInfo@nodes$nodeX
y <- gx@renderInfo@nodes$nodeY
#x and y are named vectors with node names and x / y coordinates
#to get the names of the nodes on the top rank:
topNodes1 <- names(y[y==max(y)])