% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/add_edge_clone.R
\name{add_edge_clone}
\alias{add_edge_clone}
\title{Add a clone of an existing edge to the graph}
\usage{
add_edge_clone(graph, edge, from, to)
}
\arguments{
\item{graph}{A graph object of class \code{dgr_graph}.}

\item{edge}{An edge ID corresponding to the graph edge to be cloned.}

\item{from}{The outgoing node from which the edge is connected.}

\item{to}{The incoming nodes to which each edge is connected.}
}
\value{
A graph object of class \code{dgr_graph}.
}
\description{
Add a new edge to a graph object of class \code{dgr_graph} which is a clone of an
edge already in the graph. All edge attributes are preserved.
}
\examples{
# Create a graph with a path of
# 2 nodes; supply a common `rel`
# edge attribute for all edges
# in this path and then add a
# `color` edge attribute
graph <-
  create_graph() |>
  add_path(
    n = 2,
    rel = "a") |>
  select_last_edges_created() |>
  set_edge_attrs(
    edge_attr = color,
    values = "steelblue") |>
  clear_selection()

# Display the graph's internal
# edge data frame
graph |> get_edge_df()

# Create a new node (will have
# node ID of `3`) and then
# create an edge between it and
# node `1` while reusing the edge
# attributes of edge `1` -> `2`
# (edge ID `1`)
graph_2 <-
  graph |>
  add_node() |>
  add_edge_clone(
    edge = 1,
    from = 3,
      to = 1)

# Display the graph's internal
# edge data frame
graph_2 |> get_edge_df()

# The same change can be performed
# with some helper functions in the
# `add_edge_clone()` function call
graph_3 <-
  graph |>
    add_node()

graph_3 <-
  graph_3 |>
    add_edge_clone(
      edge = get_last_edges_created(graph_3),
      from = get_last_nodes_created(graph_3),
      to = 1)

# Display the graph's internal
# edge data frame
graph_3 |> get_edge_df()

}
\seealso{
Other edge creation and removal: 
\code{\link{add_edge}()},
\code{\link{add_edge_df}()},
\code{\link{add_edges_from_table}()},
\code{\link{add_edges_w_string}()},
\code{\link{add_forward_edges_ws}()},
\code{\link{add_reverse_edges_ws}()},
\code{\link{copy_edge_attrs}()},
\code{\link{create_edge_df}()},
\code{\link{delete_edge}()},
\code{\link{delete_edges_ws}()},
\code{\link{delete_loop_edges_ws}()},
\code{\link{drop_edge_attrs}()},
\code{\link{edge_data}()},
\code{\link{join_edge_attrs}()},
\code{\link{mutate_edge_attrs}()},
\code{\link{mutate_edge_attrs_ws}()},
\code{\link{recode_edge_attrs}()},
\code{\link{rename_edge_attrs}()},
\code{\link{rescale_edge_attrs}()},
\code{\link{rev_edge_dir}()},
\code{\link{rev_edge_dir_ws}()},
\code{\link{set_edge_attr_to_display}()},
\code{\link{set_edge_attrs}()},
\code{\link{set_edge_attrs_ws}()}
}
\concept{edge creation and removal}
