Skip to contents

Low-level renderer: takes a GraphModel (or a plain list with nodes, edges, directed) and produces an interactive network htmlwidget backed by Sigma.js + graphology. Most users call draw_network() instead.

Usage

draw_graph(
  model,
  layout = "force",
  node_size = 10,
  edge_scale = 3,
  node_opacity = 0.95,
  edge_opacity = 0.4,
  show_labels = TRUE,
  scale_by_degree = TRUE,
  color_by_group = FALSE,
  resolution = 1,
  blend_edges = FALSE,
  palette = palette_colors(rtemis_colors),
  node_color = rtemis_colors[["teal"]],
  positive_color = rtemis_colors[["teal"]],
  negative_color = "#ff9e1f",
  title = NULL,
  theme = NULL,
  width = NULL,
  height = NULL,
  element_id = NULL,
  filename = NULL
)

Arguments

model

GraphModel or named list: The graph to render.

layout

Character {"force", "circular", "circlepack", "random"}: Layout algorithm. "force" is ForceAtlas2.

node_size

Numeric [0, Inf): Base node radius in screen pixels.

edge_scale

Numeric [0, Inf): Multiplier mapping normalized edge weight to stroke width.

node_opacity

Numeric [0, 1]: Node fill opacity.

edge_opacity

Numeric [0, 1]: Edge stroke opacity.

show_labels

Logical: Whether to render node labels.

scale_by_degree

Logical: Scale each node's radius by its value (weighted degree); when FALSE all nodes use the base size.

color_by_group

Logical: Color nodes by detected community (Louvain) instead of a single hue.

resolution

Numeric [0, Inf): Louvain resolution; higher yields more, smaller communities.

blend_edges

Logical: Color each edge as the blend of its two endpoint node colors instead of by sign.

palette

Character: Categorical colors for communities.

node_color

Character: Single node color used when color_by_group is FALSE.

positive_color

Character: Edge color for positive-sign edges.

negative_color

Character: Edge color for negative-sign edges.

title

Optional Character: Title shown above the network.

theme

Optional Theme, list, or NA: Theme override. NULL enables light/dark auto-detection (matching draw()).

width

Optional Character or Numeric: Widget width.

height

Optional Character or Numeric: Widget height.

element_id

Optional Character: Explicit element ID.

filename

Optional Character: Static export of network widgets is not yet supported. Supplying a path raises an error.

Value

htmlwidget.

Examples

model <- GraphModel(
  nodes = list(GraphNode(id = "a"), GraphNode(id = "b")),
  edges = list(GraphEdge(source = "a", target = "b")),
  directed = FALSE
)
draw_graph(model)