Skip to contents

Renders the top-n_hubs function nodes (by PageRank) and their one-hop neighbours as an interactive Graphviz widget via DiagrammeR::grViz(). Nodes are grouped into dashed sub-graph boxes by source file and coloured by node type; node width scales with relative PageRank importance. In an interactive session the widget appears in the RStudio Viewer or a browser tab.

Usage

# S3 method for class 'rrlm_graph'
plot(
  x,
  n_hubs = 15L,
  layout = c("dot", "neato", "fdp", "sfdp", "circo"),
  file = NULL,
  width = 1400L,
  height = 900L,
  ...
)

Arguments

x

An rrlm_graph object.

n_hubs

Integer(1). Number of top-PageRank function hub nodes to show. Default 15L.

layout

Character(1). Graphviz layout engine passed to the DOT layout attribute. One of "dot" (hierarchical, default), "neato", "fdp", "sfdp", or "circo".

file

Character(1) or NULL. Optional output file path.

width, height

Integer(1). Used only when file is a raster or vector path (.png, .pdf, .svg): sets the viewport size in pixels that webshot2::webshot() renders. Has no effect on the interactive widget, which fills 100\ pan-and-zoom via injected vanilla JS. Defaults 1400L x 900L.

...

Ignored; kept for S3 dispatch compatibility.

Value

When file is NULL (default), an htmlwidget from DiagrammeR::grViz() is returned visibly so it prints in the viewer. The widget fills 100\ cursor), drag to pan, double-click to reset. When file is supplied, x is returned invisibly.

Details

Interaction (no plugins required)

  • Scroll – zoom in / out centred on the cursor.

  • Click-drag – pan the graph.

  • Pinch (touch) – zoom on mobile/tablet.

  • Double-click – reset to the original fit-to-screen view.

Node colours:

  • User functions – "#4682B4" (steelblue)

  • Package nodes – "#C8D8E8" (pale blue, smaller)

  • Test files – "#3CB371" (seagreen3)

Examples

if (FALSE) { # \dontrun{
g <- build_rrlm_graph("mypkg")
plot(g)
plot(g, n_hubs = 10L, layout = "neato")
plot(g, file = "graph.html")
plot(g, file = "graph.png", width = 1600L, height = 1000L)
} # }