1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/is_edge_present.R
3\name{is_edge_present}
4\alias{is_edge_present}
5\title{Determine whether a specified edge is present}
6\usage{
7is_edge_present(graph, edge = NULL, from = NULL, to = NULL)
8}
9\arguments{
10\item{graph}{A graph object of class \code{dgr_graph}.}
11
12\item{edge}{An edge ID value to test for presence in the graph. If a single,
13numeric value is provided then values for \code{from} or \code{to} needn't be
14supplied.}
15
16\item{from}{A node ID from which the edge is outgoing, or, the label
17associated with the node. For an undirected graph, the value in \code{from} can
18be interchangeable with that in \code{to}.}
19
20\item{to}{A node ID to which the edge is incoming, or, the label associated
21with the node. For an undirected graph, the value in \code{to} can be
22interchangeable with that in \code{from}.}
23}
24\value{
25A logical value.
26}
27\description{
28From a graph object of class \code{dgr_graph}, determine whether an edge (defined
29by a pair of node IDs or node label values) is present.
30}
31\examples{
32# Create a simple graph with
33# a path of four nodes
34graph <-
35  create_graph() \%>\%
36  add_path(
37    n = 4,
38    type = "path",
39    label = c("one", "two",
40              "three", "four"))
41
42# Find out if edge ID `3`
43# is present in the graph
44graph \%>\%
45  is_edge_present(edge = 3)
46
47# Determine if there are any edges
48# with the definition `1` -> `2`
49graph \%>\%
50  is_edge_present(
51    from = 1,
52    to = 2)
53
54# Determine if there are any edges
55# with the definition `4` -> `5`
56graph \%>\%
57  is_edge_present(
58    from = 4,
59    to = 5)
60
61# Determine whether an edge,
62# defined by its labels as
63# `two` -> `three`, exists in
64# the graph
65graph \%>\%
66  is_edge_present(
67    from = "two",
68    to = "three")
69
70# Set the graph as undirected
71# and determine whether an
72# edge between nodes with labels
73# `three` and `two` exists
74graph \%>\%
75  set_graph_undirected() \%>\%
76  is_edge_present(
77    from = "three",
78    to = "two")
79
80}
81