rigraphvertex-attributestkplot

Display additional information on vertex of a graph


I have an oriented graph, using the following example

ba <-  sample_pa(n=100, power=1, m=1,  directed=T)
V(ba)$color<-"yellow"
tkplot(ba , layout=layout.fruchterman.reingold(ba), canvas.width=1024,canvas.height=768)

I would like to find the way to display additional information when I rightclick on a vertex or having the display of the information using a tooltip that appears when i move the mouse on each of the vertex. I tried to set attributes to the vertex but I can't find the way to display them.


Solution

  • I dunno about tkplot, however here's an alternative that displays a tooltip on hovering over the edge. The same works for vertices, too:

    library(igraph)
    library(visNetwork)
    library(fortunes)
    set.seed(1)
    ba <-  sample_pa(n=100, power=1, m=1,  directed=T)
    V(ba)$color<-"yellow"
    E(ba)$title <- sapply(1:ecount(ba), function(x) paste(strwrap(fortune(x)$quote, 40L), collapse="<br>"))
    visIgraph(ba) %>% 
      visEdges(color = "black") %>% 
      visIgraphLayout("layout.fruchterman.reingold") %>%
      visOptions(width = "1600", height = "1200")
    

    enter image description here