Generate edge layout coordinates for netify visualization
Source:R/get_edge_layout.R
get_edge_layout.Rd
get_edge_layout
prepares edge data for network visualization by calculating
start and end coordinates for line segments representing edges. This function
maps edges from a netify object to their corresponding node positions as
determined by a layout algorithm.
Arguments
- netlet
A netify object (class "netify") containing the network structure from which edges will be extracted.
- nodes_layout
A data.frame or matrix containing node positions, or a list of such objects for longitudinal networks. Each element must include columns:
actor: Character string identifying each node
x: Numeric x-coordinate of the node position
y: Numeric y-coordinate of the node position
For longitudinal networks, provide a named list where:
Names correspond to time periods in the netify object
Each element follows the structure described above
Time period names must match those in the netify object
- ig_netlet
An optional pre-converted igraph object. If provided, this function will use it directly instead of converting the netify object again.
Value
Depending on the input netify object:
Cross-sectional: A list containing one data.frame with columns:
from
: Source node nameto
: Target node namex1
,y1
: Coordinates of the source nodex2
,y2
: Coordinates of the target node
Longitudinal: A named list of data.frames (one per time period) with the same structure as above
The output maintains the same temporal structure as the input netify object.
Details
This function performs the following operations:
Edge extraction:
Converts the netify object to igraph format internally
Extracts the edge list preserving edge directions
Handles both cross-sectional and longitudinal networks
Coordinate mapping:
Matches each edge endpoint to its corresponding node position
Creates a complete set of coordinates for drawing edges
Preserves the temporal structure for longitudinal networks
Use in visualization:
This function is typically used as part of a visualization pipeline:
Create node layout using
get_node_layout()
or a custom layout algorithmGenerate edge coordinates using this function
Pass both to visualization functions for plotting
Note
The nodes_layout structure must exactly match the actors and time periods in the netify object. Missing actors in the layout will result in NA coordinates for their associated edges.
For longitudinal networks, ensure that the names of the nodes_layout list match the time period labels in the netify object (e.g., "2008", "2009").
This function always returns a list structure for consistency, even for cross-sectional networks where the list contains only one element.