Skip to contents

The complete, validated render spec for a Sigma.js network: a GraphModel (the data) plus all visual styling and an optional title. This is the Sigma analog of EChartsOption – the single object draw() dispatches on to emit a rtemis-graph widget. Theme is not a property here; like every backend, theming is supplied to draw() and resolved uniformly.

Usage

SigmaOption(
  model = NULL,
  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 = as.character(rtemis_colors),
  node_color = rtemis_colors[["teal"]],
  positive_color = rtemis_colors[["teal"]],
  negative_color = "#ff9e1f",
  title = NULL
)

Arguments

model

GraphModel or named list: The graph to render (a list must contain a nodes element).

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.

Value

SigmaOption object.

Details

Most users never touch this directly – draw_network() and draw_graph() build it – but power users can construct it for full control: draw(SigmaOption(model = GraphModel(...), layout = "circular")).

Its to_list() produces the { model, style, title } payload consumed by the rtemis-graph htmlwidget binding.

Examples

model <- GraphModel(
  nodes = list(GraphNode(id = "a"), GraphNode(id = "b")),
  edges = list(GraphEdge(source = "a", target = "b")),
  directed = FALSE
)
SigmaOption(model = model, layout = "force")
#> <rtemis.draw::SigmaOption>
#>  @ model          : <rtemis.draw::GraphModel>
#>  .. @ nodes   :List of 2
#>  .. .. $ : <rtemis.draw::GraphNode>
#>  .. ..  ..@ id   : chr "a"
#>  .. ..  ..@ label: NULL
#>  .. ..  ..@ value: NULL
#>  .. ..  ..@ group: NULL
#>  .. .. $ : <rtemis.draw::GraphNode>
#>  .. ..  ..@ id   : chr "b"
#>  .. ..  ..@ label: NULL
#>  .. ..  ..@ value: NULL
#>  .. ..  ..@ group: NULL
#>  .. @ edges   :List of 1
#>  .. .. $ : <rtemis.draw::GraphEdge>
#>  .. ..  ..@ source: chr "a"
#>  .. ..  ..@ target: chr "b"
#>  .. ..  ..@ weight: NULL
#>  .. ..  ..@ sign  : NULL
#>  .. @ directed: logi FALSE
#>  @ layout         : chr "force"
#>  @ node_size      : num 10
#>  @ edge_scale     : num 3
#>  @ node_opacity   : num 0.95
#>  @ edge_opacity   : num 0.4
#>  @ show_labels    : logi TRUE
#>  @ scale_by_degree: logi TRUE
#>  @ color_by_group : logi FALSE
#>  @ resolution     : num 1
#>  @ blend_edges    : logi FALSE
#>  @ palette        : chr [1:15] "#6CA3A0" "#F08904" "#BE2E5F" "#B3CFE8" "#0F6A66" ...
#>  @ node_color     : chr "#6CA3A0"
#>  @ positive_color : chr "#6CA3A0"
#>  @ negative_color : chr "#ff9e1f"
#>  @ title          : NULL