Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

edge_types

Querying edge types


Description

These functions lets the user query whether the edges in a graph is of a specific type. All functions return a logical vector giving whether each edge in the graph corresponds to the specific type.

Usage

edge_is_multiple()

edge_is_loop()

edge_is_mutual()

edge_is_from(from)

edge_is_to(to)

edge_is_between(from, to, ignore_dir = !graph_is_directed())

edge_is_incident(i)

Arguments

from, to, i

A vector giving node indices

ignore_dir

Is both directions of the edge allowed

Value

A logical vector of the same length as the number of edges in the graph

Functions

  • edge_is_multiple: Query whether each edge has any parallel siblings

  • edge_is_loop: Query whether each edge is a loop

  • edge_is_mutual: Query whether each edge has a sibling going in the reverse direction

  • edge_is_from: Query whether an edge goes from a set of nodes

  • edge_is_to: Query whether an edge goes to a set of nodes

  • edge_is_between: Query whether an edge goes between two sets of nodes

  • edge_is_incident: Query whether an edge goes from or to a set of nodes

Examples

create_star(10, directed = TRUE, mutual = TRUE) %>%
  activate(edges) %>%
  sample_frac(0.7) %>%
  mutate(single_edge = !edge_is_mutual())

tidygraph

A Tidy API for Graph Manipulation

v1.2.0
MIT + file LICENSE
Authors
Thomas Lin Pedersen [cre, aut] (<https://orcid.org/0000-0002-5147-4711>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.