Types API Reference

This page documents the core data types in NDTV.jl.

Layout Types

NDTV.DynamicLayout — Type
DynamicLayout{T, Time}

Layout positions for dynamic network visualization across time. All dictionaries are keyed by stable vertex IDs (the dynamic network's own IDs), never by per-slice indices; every frame holds a position for every vertex (inactive vertices keep a carried position and are not drawn).

Fields

  • positions::Vector{Dict{T, Tuple{Float64, Float64}}}: Positions per frame
  • times::Vector{Time}: Frame time points (the slice onsets for interval slices)
  • bounds::Tuple{Float64, Float64, Float64, Float64}: (xmin, xmax, ymin, ymax)
  • frame_edges::Vector{Vector{Tuple{T, T}}}: Active edges per frame
  • frame_active::Vector{Vector{T}}: Active vertices per frame

Example

using NDTV
dl = DynamicLayout([Dict(1 => (0.0, 0.0)), Dict(1 => (1.0, 1.0))], [0.0, 1.0])
length(dl), dl.bounds          # (2, (0.0, 1.0, 0.0, 1.0))
source
NDTV.InterpolatedLayout — Type
InterpolatedLayout{T, Time}

Layout with smooth interpolation between time points (:linear or :ease); query it with get_position.

Example

using NDTV
base = DynamicLayout([Dict(1 => (0.0, 0.0)), Dict(1 => (1.0, 2.0))], [0.0, 1.0])
il = InterpolatedLayout(base; interpolation=:ease)
il.interpolation               # :ease
source

Layout Algorithm Types

NDTV.FRLayout — Type
FRLayout(; iterations=100, cooling=0.95, k=1.0)

Fruchterman-Reingold force-directed layout parameters. Directed networks are laid out on their symmetrised graph (a mutual pair attracts once), as R's network.layout.fruchtermanreingold does.

Example

using NDTV, NetworkCore, Random
net = network(4); add_edge!(net, 1, 2); add_edge!(net, 2, 3)
pos = compute_layout(net, FRLayout(; iterations=50); rng=Xoshiro(1))
length(pos)                    # 4
source
NDTV.MDSLayout — Type
MDSLayout()

Classical multidimensional scaling (Torgerson scaling) of the geodesic distance matrix (of the symmetrised graph on directed networks). The squared-distance matrix is double-centred and the top two eigenvectors of the resulting Gram matrix give the coordinates, so Euclidean distances in the plane approximate graph distances. Deterministic and non-iterative (a single eigendecomposition, no random start, no rng dependence). Each connected component is scaled on its own and the components are packed side by side (largest first), so disconnected parts neither collapse onto each other nor need an invented "unreachable" distance.

This is not Kamada-Kawai

The true Kamada–Kawai algorithm (Kamada & Kawai 1989) iteratively minimizes a spring energy $\sum_{i<j} \tfrac{1}{2} k_{ij}(\|p_i - p_j\| - d_{ij})^2$ by Newton–Raphson on vertex positions. Classical MDS solves an eigenproblem in closed form and optimizes a different (strain, not stress) criterion. The two give similar pictures on small well-connected graphs but are different algorithms with different fixed points. Kamada–Kawai is not implemented here.

Example

using NDTV, NetworkCore
net = network(3; directed=false); add_edge!(net, 1, 2); add_edge!(net, 2, 3)
pos = compute_layout(net, MDSLayout())
pos[2]                         # the middle of the path sits at the centre
source
NDTV.CircleLayout — Type
CircleLayout(; radius=1.0, start_angle=0.0)

Vertices evenly spaced on a circle (deterministic). In a dynamic layout every vertex keeps its slot on the circle across frames.

Example

using NDTV, NetworkCore
compute_layout(network(4), CircleLayout(; radius=2.0))[1]   # (2.0, 0.0)
source
NDTV.RandomLayout — Type
RandomLayout(; xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0)

Uniform random positions within the given bounds (drawn from the rng passed to compute_layout).

Example

using NDTV, NetworkCore, Random
pos = compute_layout(network(3), RandomLayout(; xmax=10.0); rng=Xoshiro(2))
all(0 <= p[1] <= 10 for p in values(pos))   # true
source