Learn R Programming

cograph (version 1.5.2)

detect_duplicate_edges: Detect Duplicate Edges in Undirected Network

Description

Identifies edges that appear multiple times between the same pair of nodes. For undirected networks, edges A->B and B->A are considered duplicates. For directed networks, only identical from->to pairs are duplicates.

Usage

detect_duplicate_edges(edges)

Value

A list with two components:

has_duplicates

Logical indicating whether any duplicates were found.

info

A list of duplicate details, where each element contains: nodes (the node pair), count (number of edges), and weights (vector of weights if available).

Arguments

edges

Data frame with from and to columns (and optionally weight).

Details

This function is useful for cleaning network data before visualization. Duplicate edges can arise from:

  • Data collection errors (same edge recorded twice)

  • Combining multiple data sources

  • Converting from formats that allow multi-edges

  • Edge lists that include both A->B and B->A for undirected networks

The function creates canonical keys by sorting node pairs (lower index first), so edges 1->2 and 2->1 map to the same key "1-2" in undirected mode.

See Also

aggregate_duplicate_edges for combining duplicates into single edges