R で igraph を使用して小さなネットワークをプロットしようとしています。ネットワーク内の各頂点には、そのラベルに相当する名前があります。各頂点に、そのラベルにちょうど収まる大きさの長方形のシンボルを持たせたいと思います。
これが私の主なインスピレーションです。
igraphでこれを行う最良の方法は何ですか?
編集:詳細
コードはこちら
jsonToNM <- function(jfile, directed=TRUE) {
# Requires "rjson" and "igraph"
nm.json <- fromJSON(file=jfile)
nm.graph <- c()
# Initialize the graph with the given nodes
g <- graph.empty(n=length(nm.json), directed=directed)
# Add their names
V(g)$name <- names(nm.json)
V(g)$label <- V(g)$name
# Now, add the edges
for(i in 1:length(nm.json)) {
# If the node has a "connected" field,
# then we note the connections by looking
# the names up.
if(length(nm.json[[i]]$connected > 0)) {
for(j in 1:length(nm.json[[i]]$connected)) {
# Add the entry
g <- g + edge(names(nm.json)[i],
nm.json[[i]]$connected[j])
}
}
}
plot(g, vertex.label.dist=1.5)
}
そして、現在の出力は以下です。
私の目標は、ラベルを頂点グラフィックの内側に配置し、頂点の幅を広げてラベルを収容することです。