1
votes

I have an igraph (R) graph object named g like this:

IGRAPH UNW- 6 5 -- 
+ attr: name (v/c), weight (e/n)
+ edges (vertex names):
[1] 1--4 1--5 1--6 4--2 3--5

I run clustering on it like this:

c1 <-  cluster_fast_greedy(g)

I then convert it to a hclust object like this:

hc <-  as.hclust(c1)

Checking the labels at this point yields:

> hc$labels
[1] "1" "4" "3" "5" "6" "2"

Then using networkD3, I convert that to a radialNetwork

rad <- as.radialNetwork(hc)

I plot it with (for example):

D3graph <- radialNetwork(List = rad, 
                         fontSize = 10, 
                         opacity = 0.8, 
                         margin=1, 
                         fontFamily = "sans-serif",
                         nodeColour = "grey",
                         nodeStroke = "white"
                         )

But a node named hc, and a set of unnamed nodes turn up in the dendrogram. Like this:enter image description here

1

1 Answers

2
votes

You can set the root node name in the as.radialNetwork function to a zero-length string...

library(networkD3)
hc <- hclust(dist(USArrests), "ave")
rad <- as.radialNetwork(hc, '')
radialNetwork(List = rad)

I can't see what your object g is without a minimal reproducible example, so I can't explain why your nodes are not labeled, but I suspect that happens in either your cluster_fast_greedy function or the as.hclust function. hc$labels should show what your labels are set to (or are not set to) before you get to the as.radialNetwork function.