1% Generated by roxygen2: do not edit by hand 2% Please edit documentation in R/transform_to_subgraph_ws.R 3\name{transform_to_subgraph_ws} 4\alias{transform_to_subgraph_ws} 5\title{Create a subgraph using a node or edge selection} 6\usage{ 7transform_to_subgraph_ws(graph) 8} 9\arguments{ 10\item{graph}{A graph object of class \code{dgr_graph}.} 11} 12\value{ 13A graph object of class \code{dgr_graph}. 14} 15\description{ 16Create a subgraph based on a selection of nodes or edges stored in the graph 17object. 18} 19\details{ 20This function makes use of an active selection of nodes or edges (and the 21function ending with \verb{_ws} hints at this). 22 23Selections of nodes can be performed using the following node selection 24(\verb{select_*()}) functions: \code{\link[=select_nodes]{select_nodes()}}, \code{\link[=select_last_nodes_created]{select_last_nodes_created()}}, 25\code{\link[=select_nodes_by_degree]{select_nodes_by_degree()}}, \code{\link[=select_nodes_by_id]{select_nodes_by_id()}}, or 26\code{\link[=select_nodes_in_neighborhood]{select_nodes_in_neighborhood()}}. 27 28Selections of edges can be performed using the following edge selection 29(\verb{select_*()}) functions: \code{\link[=select_edges]{select_edges()}}, \code{\link[=select_last_edges_created]{select_last_edges_created()}}, 30\code{\link[=select_edges_by_edge_id]{select_edges_by_edge_id()}}, or \code{\link[=select_edges_by_node_id]{select_edges_by_node_id()}}. 31 32Selections of nodes or edges can also be performed using the following 33traversal (\verb{trav_*()}) functions: \code{\link[=trav_out]{trav_out()}}, \code{\link[=trav_in]{trav_in()}}, \code{\link[=trav_both]{trav_both()}}, 34\code{\link[=trav_out_node]{trav_out_node()}}, \code{\link[=trav_in_node]{trav_in_node()}}, \code{\link[=trav_out_until]{trav_out_until()}}, \code{\link[=trav_in_until]{trav_in_until()}}, 35\code{\link[=trav_out_edge]{trav_out_edge()}}, \code{\link[=trav_in_edge]{trav_in_edge()}}, \code{\link[=trav_both_edge]{trav_both_edge()}}, or 36\code{\link[=trav_reverse_edge]{trav_reverse_edge()}}. 37} 38\examples{ 39# Create a node data frame (ndf) 40ndf <- 41 create_node_df( 42 n = 6, 43 value = 44 c(3.5, 2.6, 9.4, 45 2.7, 5.2, 2.1)) 46 47# Create an edge data frame (edf) 48edf <- 49 create_edge_df( 50 from = c(1, 2, 4, 5, 2, 6, 2), 51 to = c(2, 4, 1, 3, 5, 5, 4)) 52 53# Create a graph 54graph <- 55 create_graph( 56 nodes_df = ndf, 57 edges_df = edf) 58 59# Create a selection of nodes, this selects 60# nodes `1`, `3`, and `5` 61graph <- 62 graph \%>\% 63 select_nodes( 64 conditions = value > 3) 65 66# Create a subgraph based on the selection 67subgraph <- 68 graph \%>\% 69 transform_to_subgraph_ws() 70 71# Display the graph's node data frame 72subgraph \%>\% get_node_df() 73 74# Display the graph's edge data frame 75subgraph \%>\% get_edge_df() 76 77# Create a selection of edges, this selects 78# edges `1`, `2` 79graph <- 80 graph \%>\% 81 clear_selection() \%>\% 82 select_edges( 83 edges = c(1,2)) 84 85# Create a subgraph based on the selection 86subgraph <- 87 graph \%>\% 88 transform_to_subgraph_ws() 89 90# Display the graph's node data frame 91subgraph \%>\% get_node_df() 92 93# Display the graph's edge data frame 94subgraph \%>\% get_edge_df() 95 96} 97