tidygraph/ 0000755 0001762 0000144 00000000000 13656450173 012257 5 ustar ligges users tidygraph/NAMESPACE 0000644 0001762 0000144 00000037075 13656437446 013522 0 ustar ligges users # Generated by roxygen2: do not edit by hand
S3method(activate,grouped_tbl_graph)
S3method(activate,morphed_tbl_graph)
S3method(activate,tbl_graph)
S3method(anti_join,tbl_graph)
S3method(arrange,morphed_tbl_graph)
S3method(arrange,tbl_graph)
S3method(as.data.frame,tbl_graph)
S3method(as.igraph,tbl_graph)
S3method(as.list,tbl_graph)
S3method(as_tbl_graph,Node)
S3method(as_tbl_graph,data.frame)
S3method(as_tbl_graph,default)
S3method(as_tbl_graph,dendrogram)
S3method(as_tbl_graph,evonet)
S3method(as_tbl_graph,graphAM)
S3method(as_tbl_graph,graphBAM)
S3method(as_tbl_graph,graphNEL)
S3method(as_tbl_graph,hclust)
S3method(as_tbl_graph,igraph)
S3method(as_tbl_graph,list)
S3method(as_tbl_graph,matrix)
S3method(as_tbl_graph,network)
S3method(as_tbl_graph,phylo)
S3method(as_tbl_graph,tbl_graph)
S3method(as_tibble,tbl_graph)
S3method(convert,tbl_graph)
S3method(crystallise,morphed_tbl_graph)
S3method(distinct,morphed_tbl_graph)
S3method(distinct,tbl_graph)
S3method(filter,morphed_tbl_graph)
S3method(filter,tbl_graph)
S3method(full_join,tbl_graph)
S3method(group_by,morphed_tbl_graph)
S3method(group_by,tbl_graph)
S3method(group_data,tbl_graph)
S3method(group_indices,tbl_graph)
S3method(group_keys,tbl_graph)
S3method(group_size,tbl_graph)
S3method(group_vars,tbl_graph)
S3method(groups,tbl_graph)
S3method(inner_join,tbl_graph)
S3method(left_join,tbl_graph)
S3method(morph,morphed_tbl_graph)
S3method(morph,tbl_graph)
S3method(mutate,morphed_tbl_graph)
S3method(mutate,tbl_graph)
S3method(n_groups,tbl_graph)
S3method(print,morphed_tbl_graph)
S3method(print,tbl_graph)
S3method(pull,morphed_tbl_graph)
S3method(pull,tbl_graph)
S3method(rename,morphed_tbl_graph)
S3method(rename,tbl_graph)
S3method(reroute,morphed_tbl_graph)
S3method(reroute,tbl_graph)
S3method(right_join,tbl_graph)
S3method(sample_frac,morphed_tbl_graph)
S3method(sample_frac,tbl_graph)
S3method(sample_n,morphed_tbl_graph)
S3method(sample_n,tbl_graph)
S3method(select,morphed_tbl_graph)
S3method(select,tbl_graph)
S3method(semi_join,tbl_graph)
S3method(slice,morphed_tbl_graph)
S3method(slice,tbl_graph)
S3method(tbl_vars,tbl_graph)
S3method(ungroup,grouped_tbl_graph)
S3method(ungroup,morphed_tbl_graph)
S3method(ungroup,tbl_graph)
S3method(unmorph,morphed_tbl_graph)
export("%>%")
export("%E>%")
export("%N>%")
export(.E)
export(.G)
export(.N)
export(.graph_context)
export(.register_graph_context)
export(activate)
export(active)
export(anti_join)
export(arrange)
export(as.igraph)
export(as_tbl_graph)
export(as_tibble)
export(bfs_after)
export(bfs_before)
export(bfs_dist)
export(bfs_parent)
export(bfs_rank)
export(bind_edges)
export(bind_graphs)
export(bind_nodes)
export(centrality_alpha)
export(centrality_authority)
export(centrality_betweenness)
export(centrality_betweenness_communicability)
export(centrality_betweenness_current)
export(centrality_betweenness_network)
export(centrality_betweenness_rsp_net)
export(centrality_betweenness_rsp_simple)
export(centrality_closeness)
export(centrality_closeness_generalised)
export(centrality_closeness_harmonic)
export(centrality_closeness_residual)
export(centrality_communicability)
export(centrality_communicability_even)
export(centrality_communicability_odd)
export(centrality_decay)
export(centrality_degree)
export(centrality_edge_betweenness)
export(centrality_eigen)
export(centrality_expected)
export(centrality_hub)
export(centrality_information)
export(centrality_integration)
export(centrality_katz)
export(centrality_manual)
export(centrality_pagerank)
export(centrality_power)
export(centrality_random_walk)
export(centrality_subgraph)
export(centrality_subgraph_even)
export(centrality_subgraph_odd)
export(contains)
export(convert)
export(create_bipartite)
export(create_chordal_ring)
export(create_citation)
export(create_complete)
export(create_de_bruijn)
export(create_empty)
export(create_kautz)
export(create_lattice)
export(create_notable)
export(create_path)
export(create_ring)
export(create_star)
export(create_tree)
export(crystallise)
export(crystallize)
export(dfs_dist)
export(dfs_parent)
export(dfs_rank)
export(dfs_rank_out)
export(distinct)
export(edge_is_between)
export(edge_is_from)
export(edge_is_incident)
export(edge_is_loop)
export(edge_is_multiple)
export(edge_is_mutual)
export(edge_is_to)
export(ends_with)
export(everything)
export(filter)
export(fortify.tbl_graph)
export(full_join)
export(graph_adhesion)
export(graph_assortativity)
export(graph_asym_count)
export(graph_automorphisms)
export(graph_clique_count)
export(graph_clique_num)
export(graph_component_count)
export(graph_diameter)
export(graph_girth)
export(graph_is_bipartite)
export(graph_is_chordal)
export(graph_is_complete)
export(graph_is_connected)
export(graph_is_dag)
export(graph_is_directed)
export(graph_is_forest)
export(graph_is_isomorphic_to)
export(graph_is_simple)
export(graph_is_subgraph_isomorphic_to)
export(graph_is_tree)
export(graph_join)
export(graph_mean_dist)
export(graph_min_cut)
export(graph_modularity)
export(graph_motif_count)
export(graph_mutual_count)
export(graph_order)
export(graph_radius)
export(graph_reciprocity)
export(graph_size)
export(graph_unconn_count)
export(group_biconnected_component)
export(group_by)
export(group_components)
export(group_data)
export(group_edge_betweenness)
export(group_fast_greedy)
export(group_indices)
export(group_infomap)
export(group_keys)
export(group_label_prop)
export(group_leading_eigen)
export(group_louvain)
export(group_optimal)
export(group_size)
export(group_spinglass)
export(group_vars)
export(group_walktrap)
export(groups)
export(inner_join)
export(is.tbl_graph)
export(left_join)
export(local_ave_degree)
export(local_members)
export(local_size)
export(local_transitivity)
export(local_triangles)
export(map_bfs)
export(map_bfs_back)
export(map_bfs_back_chr)
export(map_bfs_back_dbl)
export(map_bfs_back_int)
export(map_bfs_back_lgl)
export(map_bfs_chr)
export(map_bfs_dbl)
export(map_bfs_int)
export(map_bfs_lgl)
export(map_dfs)
export(map_dfs_back)
export(map_dfs_back_chr)
export(map_dfs_back_dbl)
export(map_dfs_back_int)
export(map_dfs_back_lgl)
export(map_dfs_chr)
export(map_dfs_dbl)
export(map_dfs_int)
export(map_dfs_lgl)
export(map_local)
export(map_local_chr)
export(map_local_dbl)
export(map_local_int)
export(map_local_lgl)
export(matches)
export(morph)
export(mutate)
export(mutate_all)
export(mutate_as_tbl)
export(mutate_at)
export(n)
export(n_groups)
export(node_adhesion_from)
export(node_adhesion_to)
export(node_bibcoupling_with)
export(node_bridging_score)
export(node_closeness_impact)
export(node_cocitation_with)
export(node_cohesion_from)
export(node_cohesion_to)
export(node_connectivity_impact)
export(node_constraint)
export(node_coreness)
export(node_distance_from)
export(node_distance_to)
export(node_diversity)
export(node_dominator)
export(node_eccentricity)
export(node_effective_network_size)
export(node_fareness_impact)
export(node_is_adjacent)
export(node_is_center)
export(node_is_cut)
export(node_is_isolated)
export(node_is_keyplayer)
export(node_is_leaf)
export(node_is_root)
export(node_is_simplical)
export(node_is_sink)
export(node_is_source)
export(node_is_universal)
export(node_max_flow_from)
export(node_max_flow_to)
export(node_rank_anneal)
export(node_rank_branch_bound)
export(node_rank_dendser)
export(node_rank_genetic)
export(node_rank_hclust)
export(node_rank_leafsort)
export(node_rank_mds)
export(node_rank_quadratic)
export(node_rank_spectral)
export(node_rank_spin_in)
export(node_rank_spin_out)
export(node_rank_traveller)
export(node_rank_two)
export(node_rank_visual)
export(node_similarity_with)
export(node_topo_order)
export(num_range)
export(one_of)
export(play_barabasi_albert)
export(play_barabasi_albert_aging)
export(play_bipartite)
export(play_blocks)
export(play_blocks_hierarchy)
export(play_citation_age)
export(play_citation_type)
export(play_degree)
export(play_dotprod)
export(play_erdos_renyi)
export(play_fitness)
export(play_fitness_power)
export(play_forestfire)
export(play_geometry)
export(play_growing)
export(play_islands)
export(play_preference)
export(play_preference_asym)
export(play_smallworld)
export(play_traits)
export(pull)
export(rename)
export(reroute)
export(right_join)
export(sample_frac)
export(sample_n)
export(select)
export(semi_join)
export(slice)
export(starts_with)
export(tbl_graph)
export(tbl_vars)
export(to_bfs_tree)
export(to_complement)
export(to_components)
export(to_contracted)
export(to_dfs_tree)
export(to_directed)
export(to_dominator_tree)
export(to_hierarchical_clusters)
export(to_linegraph)
export(to_local_neighborhood)
export(to_minimum_spanning_tree)
export(to_shortest_path)
export(to_simple)
export(to_split)
export(to_subcomponent)
export(to_subgraph)
export(to_undirected)
export(to_unfolded_tree)
export(top_n)
export(transmute)
export(ungroup)
export(unmorph)
export(with_graph)
importFrom(R6,R6Class)
importFrom(Rcpp,sourceCpp)
importFrom(dplyr,anti_join)
importFrom(dplyr,arrange)
importFrom(dplyr,bind_cols)
importFrom(dplyr,bind_rows)
importFrom(dplyr,contains)
importFrom(dplyr,distinct)
importFrom(dplyr,ends_with)
importFrom(dplyr,everything)
importFrom(dplyr,filter)
importFrom(dplyr,full_join)
importFrom(dplyr,group_by)
importFrom(dplyr,group_data)
importFrom(dplyr,group_indices)
importFrom(dplyr,group_keys)
importFrom(dplyr,group_rows)
importFrom(dplyr,group_size)
importFrom(dplyr,group_vars)
importFrom(dplyr,groups)
importFrom(dplyr,inner_join)
importFrom(dplyr,left_join)
importFrom(dplyr,matches)
importFrom(dplyr,mutate)
importFrom(dplyr,mutate_all)
importFrom(dplyr,mutate_at)
importFrom(dplyr,n)
importFrom(dplyr,n_groups)
importFrom(dplyr,num_range)
importFrom(dplyr,one_of)
importFrom(dplyr,pull)
importFrom(dplyr,rename)
importFrom(dplyr,right_join)
importFrom(dplyr,sample_frac)
importFrom(dplyr,sample_n)
importFrom(dplyr,select)
importFrom(dplyr,semi_join)
importFrom(dplyr,slice)
importFrom(dplyr,starts_with)
importFrom(dplyr,tbl_vars)
importFrom(dplyr,top_n)
importFrom(dplyr,transmute)
importFrom(dplyr,ungroup)
importFrom(igraph,"V<-")
importFrom(igraph,"edge_attr<-")
importFrom(igraph,"graph_attr<-")
importFrom(igraph,"vertex_attr<-")
importFrom(igraph,E)
importFrom(igraph,V)
importFrom(igraph,add_edges)
importFrom(igraph,add_vertices)
importFrom(igraph,adjacent_vertices)
importFrom(igraph,alpha_centrality)
importFrom(igraph,articulation_points)
importFrom(igraph,as.igraph)
importFrom(igraph,as_adjacency_matrix)
importFrom(igraph,as_data_frame)
importFrom(igraph,as_edgelist)
importFrom(igraph,assortativity)
importFrom(igraph,assortativity_nominal)
importFrom(igraph,authority_score)
importFrom(igraph,automorphisms)
importFrom(igraph,betweenness)
importFrom(igraph,bfs)
importFrom(igraph,bibcoupling)
importFrom(igraph,biconnected_components)
importFrom(igraph,clique_num)
importFrom(igraph,closeness)
importFrom(igraph,cluster_edge_betweenness)
importFrom(igraph,cluster_fast_greedy)
importFrom(igraph,cluster_infomap)
importFrom(igraph,cluster_label_prop)
importFrom(igraph,cluster_leading_eigen)
importFrom(igraph,cluster_louvain)
importFrom(igraph,cluster_optimal)
importFrom(igraph,cluster_spinglass)
importFrom(igraph,cluster_walktrap)
importFrom(igraph,cocitation)
importFrom(igraph,complementer)
importFrom(igraph,components)
importFrom(igraph,constraint)
importFrom(igraph,contract)
importFrom(igraph,coreness)
importFrom(igraph,count_components)
importFrom(igraph,count_max_cliques)
importFrom(igraph,count_motifs)
importFrom(igraph,count_triangles)
importFrom(igraph,decompose)
importFrom(igraph,degree)
importFrom(igraph,delete_edges)
importFrom(igraph,delete_vertices)
importFrom(igraph,dfs)
importFrom(igraph,diameter)
importFrom(igraph,distances)
importFrom(igraph,diversity)
importFrom(igraph,dominator_tree)
importFrom(igraph,dyad_census)
importFrom(igraph,eccentricity)
importFrom(igraph,ecount)
importFrom(igraph,edge_attr)
importFrom(igraph,edge_attr_names)
importFrom(igraph,edge_betweenness)
importFrom(igraph,edge_connectivity)
importFrom(igraph,ego)
importFrom(igraph,ego_size)
importFrom(igraph,eigen_centrality)
importFrom(igraph,estimate_betweenness)
importFrom(igraph,estimate_closeness)
importFrom(igraph,estimate_edge_betweenness)
importFrom(igraph,girth)
importFrom(igraph,gorder)
importFrom(igraph,graph_attr)
importFrom(igraph,graph_from_adj_list)
importFrom(igraph,graph_from_adjacency_matrix)
importFrom(igraph,graph_from_data_frame)
importFrom(igraph,graph_from_edgelist)
importFrom(igraph,graph_from_incidence_matrix)
importFrom(igraph,gsize)
importFrom(igraph,hub_score)
importFrom(igraph,induced_subgraph)
importFrom(igraph,is.directed)
importFrom(igraph,is_bipartite)
importFrom(igraph,is_chordal)
importFrom(igraph,is_connected)
importFrom(igraph,is_dag)
importFrom(igraph,is_directed)
importFrom(igraph,is_isomorphic_to)
importFrom(igraph,is_simple)
importFrom(igraph,is_subgraph_isomorphic_to)
importFrom(igraph,knn)
importFrom(igraph,local_scan)
importFrom(igraph,make_chordal_ring)
importFrom(igraph,make_de_bruijn_graph)
importFrom(igraph,make_ego_graph)
importFrom(igraph,make_empty_graph)
importFrom(igraph,make_full_bipartite_graph)
importFrom(igraph,make_full_citation_graph)
importFrom(igraph,make_full_graph)
importFrom(igraph,make_graph)
importFrom(igraph,make_kautz_graph)
importFrom(igraph,make_lattice)
importFrom(igraph,make_line_graph)
importFrom(igraph,make_ring)
importFrom(igraph,make_star)
importFrom(igraph,make_tree)
importFrom(igraph,max_flow)
importFrom(igraph,mean_distance)
importFrom(igraph,membership)
importFrom(igraph,min_cut)
importFrom(igraph,modularity)
importFrom(igraph,mst)
importFrom(igraph,page_rank)
importFrom(igraph,permute)
importFrom(igraph,power_centrality)
importFrom(igraph,radius)
importFrom(igraph,reciprocity)
importFrom(igraph,sample_asym_pref)
importFrom(igraph,sample_bipartite)
importFrom(igraph,sample_cit_cit_types)
importFrom(igraph,sample_cit_types)
importFrom(igraph,sample_degseq)
importFrom(igraph,sample_dot_product)
importFrom(igraph,sample_fitness)
importFrom(igraph,sample_fitness_pl)
importFrom(igraph,sample_forestfire)
importFrom(igraph,sample_gnm)
importFrom(igraph,sample_gnp)
importFrom(igraph,sample_grg)
importFrom(igraph,sample_growing)
importFrom(igraph,sample_hierarchical_sbm)
importFrom(igraph,sample_islands)
importFrom(igraph,sample_last_cit)
importFrom(igraph,sample_pa)
importFrom(igraph,sample_pa_age)
importFrom(igraph,sample_pref)
importFrom(igraph,sample_sbm)
importFrom(igraph,sample_smallworld)
importFrom(igraph,sample_traits)
importFrom(igraph,sample_traits_callaway)
importFrom(igraph,set_edge_attr)
importFrom(igraph,set_vertex_attr)
importFrom(igraph,shortest_paths)
importFrom(igraph,similarity)
importFrom(igraph,simplify)
importFrom(igraph,strength)
importFrom(igraph,subgraph.edges)
importFrom(igraph,subgraph_centrality)
importFrom(igraph,topo_sort)
importFrom(igraph,transitivity)
importFrom(igraph,unfold_tree)
importFrom(igraph,vertex_attr)
importFrom(igraph,vertex_attr_names)
importFrom(igraph,vertex_connectivity)
importFrom(igraph,which_loop)
importFrom(igraph,which_multiple)
importFrom(igraph,which_mutual)
importFrom(magrittr,"%>%")
importFrom(pillar,style_subtle)
importFrom(rlang,"!!!")
importFrom(rlang,"%||%")
importFrom(rlang,.data)
importFrom(rlang,UQS)
importFrom(rlang,as_quosure)
importFrom(rlang,caller_env)
importFrom(rlang,enexpr)
importFrom(rlang,enquo)
importFrom(rlang,eval_bare)
importFrom(rlang,eval_tidy)
importFrom(rlang,is_bare_list)
importFrom(rlang,list2)
importFrom(rlang,quo)
importFrom(rlang,quo_text)
importFrom(rlang,quos)
importFrom(rlang,sym)
importFrom(stats,as.dendrogram)
importFrom(stats,as.dist)
importFrom(stats,dist)
importFrom(stats,hclust)
importFrom(stats,is.leaf)
importFrom(stats,na.omit)
importFrom(stats,setNames)
importFrom(tibble,as_tibble)
importFrom(tibble,tibble)
importFrom(tibble,trunc_mat)
importFrom(tidyr,nest_legacy)
importFrom(tools,toTitleCase)
importFrom(utils,head)
importFrom(utils,modifyList)
useDynLib(tidygraph)
tidygraph/LICENSE 0000644 0001762 0000144 00000000061 13545322217 013253 0 ustar ligges users YEAR: 2017
COPYRIGHT HOLDER: Thomas Lin Pedersen
tidygraph/README.md 0000644 0001762 0000144 00000012356 13656244730 013545 0 ustar ligges users
# tidygraph
[](https://github.com/thomasp85/tidygraph/actions)
[](https://CRAN.R-project.org/package=tidygraph)
[](https://CRAN.R-project.org/package=tidygraph)
[](https://codecov.io/github/thomasp85/tidygraph?branch=master)
This package provides a tidy API for graph/network manipulation. While
network data itself is not tidy, it can be envisioned as two tidy
tables, one for node data and one for edge data. `tidygraph` provides a
way to switch between the two tables and provides `dplyr` verbs for
manipulating them. Furthermore it provides access to a lot of graph
algorithms with return values that facilitate their use in a tidy
workflow.
## An example
``` r
library(tidygraph)
play_erdos_renyi(10, 0.5) %>%
activate(nodes) %>%
mutate(degree = centrality_degree()) %>%
activate(edges) %>%
mutate(centrality = centrality_edge_betweenness()) %>%
arrange(centrality)
#> # A tbl_graph: 10 nodes and 46 edges
#> #
#> # A directed simple graph with 1 component
#> #
#> # Edge Data: 46 x 3 (active)
#> from to centrality
#> *
#> 1 1 8 1.33
#> 2 5 8 1.42
#> 3 5 3 1.75
#> 4 3 7 1.75
#> 5 5 7 1.92
#> 6 5 1 2.00
#> # … with 40 more rows
#> #
#> # Node Data: 10 x 1
#> degree
#>
#> 1 5
#> 2 6
#> 3 4
#> # … with 7 more rows
```
## Overview
`tidygraph` is a huge package that exports 280 different functions and
methods. It more or less wraps the full functionality of `igraph` in a
tidy API giving you access to almost all of the `dplyr` verbs plus a few
more, developed for use with relational data.
### More verbs
`tidygraph` adds some extra verbs for specific use in network analysis
and manipulation. The `activate()` function defines whether one is
manipulating node or edge data at the moment as shown in the example
above. `bind_edges()`, `bind_nodes()`, and `bind_graphs()` let you
expand the graph structure you’re working with, while `graph_join()`
lets you merge two graphs on some node identifier. `reroute()`, on the
other hand, lets you change the terminal nodes of the edges in the
graph.
### More algorithms
`tidygraph` wraps almost all of the graph algorithms from `igraph` and
provides a consistent interface and output that always matches the
sequence of nodes and edges. All `tidygraph` algorithm wrappers are
intended for use inside verbs where they know the context they are being
called in. In the example above it is not necessary to supply the graph
nor the node/edge IDs to `centrality_degree()` and
`centrality_edge_betweenness()` as they are aware of them already. This
leads to much clearer code and less typing.
### More maps
`tidygraph` goes beyond `dplyr` and also implements graph centric
version of the `purrr` map functions. You can now call a function on the
nodes in the order of a breadth or depth first search while getting
access to the result of the previous calls.
### More morphs
`tidygraph` lets you temporarily change the representation of your
graph, do some manipulation of the node and edge data, and then change
back to the original graph with the changes being merged in
automatically. This is powered by the new `morph()`/`unmorph()` verbs
that let you e.g. contract nodes, work on the linegraph representation,
split communities to separate graphs etc. If you wish to continue with
the morphed version, the `crystallise()` verb lets you *freeze* the
temporary representation into a proper `tbl_graph`.
### More data structure support
While `tidygraph` is powered by igraph underneath it wants everyone to
join the fun. The `as_tbl_graph()` function can easily convert
relational data from all your favourite objects, such as `network`,
`phylo`, `dendrogram`, `data.tree`, `graph`, etc. More conversion will
be added in the order I become aware of them.
## Visualisation
`tidygraph` itself does not provide any means of visualisation, but it
works flawlessly with `ggraph`. This division makes it easy to develop
the visualisation and manipulation code at different speeds depending on
where the needs arise.
## Installation
`tidygraph` is available on CRAN and can be installed simply, using
`install.packages('tidygraph')`. For the development version available
on GitHub, use the `devtools` package for installation:
``` r
# install.packages('devtools')
devtools::install_github('thomasp85/tidygraph')
```
## Thanks
`tidygraph` stands on the shoulders of particularly the `igraph` and
`dplyr`/`tidyverse` teams. It would not have happened without them, so
thanks so much to them.
## Code of Conduct
Please note that the ‘tidygraph’ project is released with a [Contributor
Code of
Conduct](https://tidygraph.data-imaginist.com/CODE_OF_CONDUCT.html). By
contributing to this project, you agree to abide by its terms.
tidygraph/man/ 0000755 0001762 0000144 00000000000 13545322217 013024 5 ustar ligges users tidygraph/man/morph.Rd 0000644 0001762 0000144 00000007657 13545322217 014457 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/morph.R
\name{morph}
\alias{morph}
\alias{unmorph}
\alias{crystallise}
\alias{crystallize}
\alias{convert}
\title{Create a temporary alternative representation of the graph to compute on}
\usage{
morph(.data, .f, ...)
unmorph(.data)
crystallise(.data)
crystallize(.data)
convert(.data, .f, ..., .select = 1, .clean = FALSE)
}
\arguments{
\item{.data}{A \code{tbl_graph} or a \code{morphed_tbl_graph}}
\item{.f}{A morphing function. See \link{morphers} for a list of provided one.}
\item{...}{Arguments passed on to the morpher}
\item{.select}{The graph to return during \code{convert()}. Either an index or the
name as created during \code{crystallise()}.}
\item{.clean}{Should references to the node and edge indexes in the original
graph be removed when using \code{convert}}
}
\value{
A \code{morphed_tbl_graph}
}
\description{
The \code{morph}/\code{unmorph} verbs are used to create temporary representations of
the graph, such as e.g. its search tree or a subgraph. A morphed graph will
accept any of the standard \code{dplyr} verbs, and changed to the data is
automatically propagated to the original graph when unmorphing. Tidygraph
comes with a range of \link{morphers}, but is it also possible to supply your own.
See Details for the requirement for custom morphers. The \code{crystallise} verb
is used to extract the temporary graph representation into a tibble
containing one separate graph per row and a \code{name} and \code{graph} column holding
the name of each graph and the graph itself respectively. \code{convert()} is a
shorthand for performing both \code{morph} and \code{crystallise} along with extracting
a single \code{tbl_graph} (defaults to the first). For morphs were you know they
only create a single graph, and you want to keep it, this is an easy way.
}
\details{
It is only possible to change and add to node and edge data from a
morphed state. Any filtering/removal of nodes and edges will not result in
removal from the main graph. However, nodes and edges not present in the
morphed state will be unaffected in the main graph when unmorphing (if new
columns were added during the morhped state they will be filled with \code{NA}).
Morphing an already morhped graph will unmorph prior to applying the new
morph.
During a morphed state, the mapping back to the original graph is stored in
\code{.tidygraph_node_index} and \code{.tidygraph_edge_index} columns. These are
accesible but protected, meaning that any changes to them with e.g. mutate
will be ignored. Furthermore, if the morph results in the merging of nodes
and/or edges the original data is stored in a \code{.data} column. This is
protected as well.
When supplying your own morphers the morphing function should accept a
\code{tbl_graph} as its first input. The provided graph will already have nodes
and edges mapped with a \code{.tidygraph_node_index} and \code{.tidygraph_edge_index}
column. The return value must be a \code{tbl_graph} or a list of \code{tbl_graph}s and
these must contain either a \code{.tidygraph_node_index} column or a
\code{.tidygraph_edge_index} column (or both). Note that it is possible for the
morph to have the edges mapped back to the original nodes and vice versa
(e.g. as with \link{to_linegraph}). In that case the edge data in the morphed
graph(s) will contain a \code{.tidygraph_node_index} column and or the node data a
\code{.tidygraph_edge_index} column. If the morphing results in the collapse of
multiple columns or edges the index columns should be converted to list
columns mapping the new node/edge back to all the nodes/edges it represents.
Furthermore the original node/edge data should be collapsed to a list of
tibbles, with the row order matching the order in the index column element.
}
\examples{
create_notable('meredith') \%>\%
mutate(group = group_infomap()) \%>\%
morph(to_contracted, group) \%>\%
mutate(group_centrality = centrality_pagerank()) \%>\%
unmorph()
}
tidygraph/man/graph_join.Rd 0000644 0001762 0000144 00000004730 13656325570 015447 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/joins.R
\name{graph_join}
\alias{graph_join}
\title{Join graphs on common nodes}
\usage{
graph_join(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)
}
\arguments{
\item{x}{A \code{tbl_graph}}
\item{y}{An object convertible to a \code{tbl_graph} using \code{\link[=as_tbl_graph]{as_tbl_graph()}}}
\item{by}{A character vector of variables to join by.
If \code{NULL}, the default, \verb{*_join()} will perform a natural join, using all
variables in common across \code{x} and \code{y}. A message lists the variables so that you
can check they're correct; suppress the message by supplying \code{by} explicitly.
To join by different variables on \code{x} and \code{y}, use a named vector.
For example, \code{by = c("a" = "b")} will match \code{x$a} to \code{y$b}.
To join by multiple variables, use a vector with length > 1.
For example, \code{by = c("a", "b")} will match \code{x$a} to \code{y$a} and \code{x$b} to
\code{y$b}. Use a named vector to match different variables in \code{x} and \code{y}.
For example, \code{by = c("a" = "b", "c" = "d")} will match \code{x$a} to \code{y$b} and
\code{x$c} to \code{y$d}.
To perform a cross-join, generating all combinations of \code{x} and \code{y},
use \code{by = character()}.}
\item{copy}{If \code{x} and \code{y} are not from the same data source,
and \code{copy} is \code{TRUE}, then \code{y} will be copied into the
same src as \code{x}. This allows you to join tables across srcs, but
it is a potentially expensive operation so you must opt into it.}
\item{suffix}{If there are non-joined duplicate variables in \code{x} and
\code{y}, these suffixes will be added to the output to disambiguate them.
Should be a character vector of length 2.}
\item{...}{Other parameters passed onto methods.}
}
\value{
A \code{tbl_graph} containing the merged graph
}
\description{
This graph-specific join method makes a full join on the nodes data and
updates the edges in the joining graph so they matches the new indexes of the
nodes in the resulting graph. Node and edge data is combined using
\code{\link[dplyr:bind_rows]{dplyr::bind_rows()}} semantic, meaning that data is matched by column name
and filled with \code{NA} if it is missing in either of the graphs.
}
\examples{
gr1 <- create_notable('bull') \%>\%
activate(nodes) \%>\%
mutate(name = letters[1:5])
gr2 <- create_ring(10) \%>\%
activate(nodes) \%>\%
mutate(name = letters[4:13])
gr1 \%>\% graph_join(gr2)
}
tidygraph/man/search_graph.Rd 0000644 0001762 0000144 00000005661 13545322217 015751 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/search.R
\name{search_graph}
\alias{search_graph}
\alias{bfs_rank}
\alias{bfs_parent}
\alias{bfs_before}
\alias{bfs_after}
\alias{bfs_dist}
\alias{dfs_rank}
\alias{dfs_rank_out}
\alias{dfs_parent}
\alias{dfs_dist}
\title{Search a graph with depth first and breath first}
\usage{
bfs_rank(root, mode = "out", unreachable = FALSE)
bfs_parent(root, mode = "out", unreachable = FALSE)
bfs_before(root, mode = "out", unreachable = FALSE)
bfs_after(root, mode = "out", unreachable = FALSE)
bfs_dist(root, mode = "out", unreachable = FALSE)
dfs_rank(root, mode = "out", unreachable = FALSE)
dfs_rank_out(root, mode = "out", unreachable = FALSE)
dfs_parent(root, mode = "out", unreachable = FALSE)
dfs_dist(root, mode = "out", unreachable = FALSE)
}
\arguments{
\item{root}{The node to start the search from}
\item{mode}{How edges are followed in the search if the graph is directed.
\code{"out"} only follows outbound edges, \code{"in"} only follows inbound edges, and
\code{"all"} or \code{"total"} follows all edges. This is ignored for undirected
graphs.}
\item{unreachable}{Should the search jump to a new component if the search is
terminated without all nodes being visited? Default to \code{FALSE} (only reach
connected nodes).}
}
\value{
An integer vector, the nature of which is determined by the function.
}
\description{
These functions wraps the \code{\link[igraph:bfs]{igraph::bfs()}} and \code{\link[igraph:dfs]{igraph::dfs()}} functions to
provide a consistent return value that can be used in \code{\link[dplyr:mutate]{dplyr::mutate()}}
calls. Each function returns an integer vector with values matching the order
of the nodes in the graph.
}
\section{Functions}{
\itemize{
\item \code{bfs_rank}: Get the succession in which the nodes are visited in a breath first search
\item \code{bfs_parent}: Get the nodes from which each node is visited in a breath first search
\item \code{bfs_before}: Get the node that was visited before each node in a breath first search
\item \code{bfs_after}: Get the node that was visited after each node in a breath first search
\item \code{bfs_dist}: Get the number of nodes between the root and each node in a breath first search
\item \code{dfs_rank}: Get the succession in which the nodes are visited in a depth first search
\item \code{dfs_rank_out}: Get the succession in which each nodes subtree is completed in a depth first search
\item \code{dfs_parent}: Get the nodes from which each node is visited in a depth first search
\item \code{dfs_dist}: Get the number of nodes between the root and each node in a depth first search
}}
\examples{
# Get the depth of each node in a tree
create_tree(10, 2) \%>\%
activate(nodes) \%>\%
mutate(depth = bfs_dist(root = 1))
# Reorder nodes based on a depth first search from node 3
create_notable('franklin') \%>\%
activate(nodes) \%>\%
mutate(order = dfs_rank(root = 3)) \%>\%
arrange(order)
}
tidygraph/man/reroute.Rd 0000644 0001762 0000144 00000002277 13545322217 015010 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/reroute.R
\name{reroute}
\alias{reroute}
\title{Change terminal nodes of edges}
\usage{
reroute(.data, from = NULL, to = NULL, subset = NULL)
}
\arguments{
\item{.data}{A tbl_graph or morphed_tbl_graph object. grouped_tbl_graph will
be ungrouped prior to rerouting}
\item{from, to}{The new indexes of the terminal nodes. If \code{NULL} nothing will
be changed}
\item{subset}{An expression evaluating to an indexing vector in the context
of the edge data.}
}
\value{
An object of the same class as .data
}
\description{
The reroute verb lets you change the beginning and end node of edges by
specifying the new indexes of the start and/or end node(s). Optionally only
a subset of the edges can be rerouted using the subset argument, which should
be an expression that are to be evaluated in the context of the edge data and
should return an index compliant vector (either logical or integer).
}
\examples{
# Switch direction of edges
create_notable('meredith') \%>\%
activate(edges) \%>\%
reroute(from = to, to = from)
# Using subset
create_notable('meredith') \%>\%
activate(edges) \%>\%
reroute(from = 1, subset = to > 10)
}
tidygraph/man/morphers.Rd 0000644 0001762 0000144 00000014223 13656245051 015157 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/morphers.R
\name{morphers}
\alias{morphers}
\alias{to_linegraph}
\alias{to_subgraph}
\alias{to_subcomponent}
\alias{to_split}
\alias{to_components}
\alias{to_complement}
\alias{to_local_neighborhood}
\alias{to_dominator_tree}
\alias{to_minimum_spanning_tree}
\alias{to_shortest_path}
\alias{to_bfs_tree}
\alias{to_dfs_tree}
\alias{to_simple}
\alias{to_contracted}
\alias{to_unfolded_tree}
\alias{to_directed}
\alias{to_undirected}
\alias{to_hierarchical_clusters}
\title{Functions to generate alternate representations of graphs}
\usage{
to_linegraph(graph)
to_subgraph(graph, ..., subset_by = NULL)
to_subcomponent(graph, node)
to_split(graph, ..., split_by = NULL)
to_components(graph, type = "weak")
to_complement(graph, loops = FALSE)
to_local_neighborhood(graph, node, order = 1, mode = "all")
to_dominator_tree(graph, root, mode = "out")
to_minimum_spanning_tree(graph, weights = NULL)
to_shortest_path(graph, from, to, mode = "out", weights = NULL)
to_bfs_tree(graph, root, mode = "out", unreachable = FALSE)
to_dfs_tree(graph, root, mode = "out", unreachable = FALSE)
to_simple(graph, remove_multiples = TRUE, remove_loops = TRUE)
to_contracted(graph, ..., simplify = TRUE)
to_unfolded_tree(graph, root, mode = "out")
to_directed(graph)
to_undirected(graph)
to_hierarchical_clusters(graph, method = "walktrap", weights = NULL, ...)
}
\arguments{
\item{graph}{A \code{tbl_graph}}
\item{...}{Arguments to pass on to \code{\link[=filter]{filter()}}, \code{\link[=group_by]{group_by()}}, or the cluster
algorithm (see \code{\link[igraph:cluster_walktrap]{igraph::cluster_walktrap()}}, \code{\link[igraph:cluster_leading_eigen]{igraph::cluster_leading_eigen()}},
and \code{\link[igraph:cluster_edge_betweenness]{igraph::cluster_edge_betweenness()}})}
\item{subset_by, split_by}{Whether to create subgraphs based on nodes or edges}
\item{node}{The center of the neighborhood for \code{to_local_neighborhood()} and
the node to that should be included in the component for \code{to_subcomponent()}}
\item{type}{The type of component to split into. Either \code{'weak'} or \code{'strong'}}
\item{loops}{Should loops be included. Defaults to \code{FALSE}}
\item{order}{The radius of the neighborhood}
\item{mode}{How should edges be followed? \code{'out'} only follows outbound
edges, \code{'in'} only follows inbound edges, and \code{'all'} follows all edges. This
parameter is ignored for undirected graphs.}
\item{root}{The root of the tree}
\item{weights}{Optional edge weights for the calculations}
\item{from, to}{The start and end node of the path}
\item{unreachable}{Should the search jump to a node in a new component when
stuck.}
\item{remove_multiples}{Should edges that run between the same nodes be
reduced to one}
\item{remove_loops}{Should edges that start and end at the same node be removed}
\item{simplify}{Should edges in the contracted graph be simplified? Defaults
to \code{TRUE}}
\item{method}{The clustering method to use. Either \code{'walktrap'}, \code{'leading_eigen'}, or \code{'edge_betweenness'}}
}
\value{
A list of \code{tbl_graph}s
}
\description{
These functions are meant to be passed into \code{\link[=morph]{morph()}} to create a temporary
alternate representation of the input graph. They are thus not meant to be
called directly. See below for detail of each morpher.
}
\section{Functions}{
\itemize{
\item \code{to_linegraph}: Convert a graph to its line graph. When unmorphing node
data will be merged back into the original edge data. Edge data will be
ignored.
\item \code{to_subgraph}: Convert a graph to a single subgraph. \code{...} is evaluated
in the same manner as \code{filter}. When unmorphing all data in the subgraph
will get merged back.
\item \code{to_subcomponent}: Convert a graph to a single component containing the specified node
\item \code{to_split}: Convert a graph into a list of separate subgraphs. \code{...}
is evaluated in the same manner as \code{group_by}. When unmorphing all data in
the subgraphs will get merged back, but in the case of \code{split_by = 'edges'}
only the first instance of node data will be used (as the same node can be
present in multiple subgraphs).
\item \code{to_components}: Split a graph into its separate components. When
unmorphing all data in the subgraphs will get merged back.
\item \code{to_complement}: Convert a graph into its complement. When unmorphing
only node data will get merged back.
\item \code{to_local_neighborhood}: Convert a graph into the local neighborhood around a
single node. When unmorphing all data will be merged back.
\item \code{to_dominator_tree}: Convert a graph into its dominator tree based on a
specific root. When unmorphing only node data will get merged back.
\item \code{to_minimum_spanning_tree}: Convert a graph into its minimum spanning tree/forest.
When unmorphing all data will get merged back.
\item \code{to_shortest_path}: Limit a graph to the shortest path between two nodes.
When unmorphing all data is merged back.
\item \code{to_bfs_tree}: Convert a graph into a breath-first search tree based on
a specific root. When unmorphing only node data is merged back.
\item \code{to_dfs_tree}: Convert a graph into a depth-first search tree based on
a specific root. When unmorphing only node data is merged back.
\item \code{to_simple}: Collapse parallel edges and remove loops in a graph.
When unmorphing all data will get merged back
\item \code{to_contracted}: Combine multiple nodes into one. \code{...}
is evaluated in the same manner as \code{group_by}. When unmorphing all
data will get merged back.
\item \code{to_unfolded_tree}: Unfold a graph to a tree or forest starting from
multiple roots (or one), potentially duplicating nodes and edges.
\item \code{to_directed}: Make a graph directed in the direction given by from and
to
\item \code{to_undirected}: Make a graph undirected
\item \code{to_hierarchical_clusters}: Convert a graph into a hierarchical clustering based on a grouping
}}
\examples{
# Compute only on a subgraph of every even node
create_notable('meredith') \%>\%
morph(to_subgraph, seq_len(graph_order()) \%\% 2 == 0) \%>\%
mutate(neighbour_count = centrality_degree()) \%>\%
unmorph()
}
tidygraph/man/evolution_games.Rd 0000644 0001762 0000144 00000007142 13654774463 016536 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/play.R
\name{evolution_games}
\alias{evolution_games}
\alias{play_citation_age}
\alias{play_forestfire}
\alias{play_growing}
\alias{play_barabasi_albert}
\alias{play_barabasi_albert_aging}
\title{Graph games based on evolution}
\usage{
play_citation_age(
n,
growth = 1,
bins = n/7100,
p_pref = (1:(bins + 1))^-3,
directed = TRUE
)
play_forestfire(
n,
p_forward,
p_backward = p_forward,
growth = 1,
directed = TRUE
)
play_growing(n, growth = 1, directed = TRUE, citation = FALSE)
play_barabasi_albert(
n,
power,
growth = 1,
growth_dist = NULL,
use_out = FALSE,
appeal_zero = 1,
directed = TRUE,
method = "psumtree"
)
play_barabasi_albert_aging(
n,
power,
power_age,
growth = 1,
growth_dist = NULL,
bins = 300,
use_out = FALSE,
appeal_zero = 1,
appeal_zero_age = 0,
directed = TRUE,
coefficient = 1,
coefficient_age = 1,
window = NULL
)
}
\arguments{
\item{n}{The number of nodes in the graph.}
\item{growth}{The number of edges added at each iteration}
\item{bins}{The number of aging bins}
\item{p_pref}{The probability that an edge will be made to an age bin.}
\item{directed}{Should the resulting graph be directed}
\item{p_forward, p_backward}{Forward and backward burning probability}
\item{citation}{Should a citation graph be created}
\item{power}{The power of the preferential attachment}
\item{growth_dist}{The distribution of the number of added edges at each iteration}
\item{use_out}{Should outbound edges be used for calculating citation probability}
\item{appeal_zero}{The appeal value for unconnected nodes}
\item{method}{The algorithm to use for graph creation. Either \code{'psumtree'},
\code{'psumtree-multiple'}, or \code{'bag'}}
\item{power_age}{The aging exponent}
\item{appeal_zero_age}{The appeal value of nodes without age}
\item{coefficient}{The coefficient of the degree dependent part of attrictiveness}
\item{coefficient_age}{The coefficient of the age dependent part of attrictiveness}
\item{window}{The aging window to take into account when calculating the preferential attraction}
}
\value{
A tbl_graph object
}
\description{
This games create graphs through different types of evolutionary mechanisms
(not necessarily in a biological sense). The nature of their algorithm is
described in detail at the linked igraph documentation.
}
\section{Functions}{
\itemize{
\item \code{play_citation_age}: Create citation graphs based on a specific age
link probability. See \code{\link[igraph:sample_last_cit]{igraph::sample_last_cit()}}
\item \code{play_forestfire}: Create graphs by simulating the spead of fire in
a forest. See \code{\link[igraph:sample_forestfire]{igraph::sample_forestfire()}}
\item \code{play_growing}: Create graphs by adding a fixed number of edges
at each iteration. See \code{\link[igraph:sample_growing]{igraph::sample_growing()}}
\item \code{play_barabasi_albert}: Create graphs based on the Barabasi-Alberts
preferential attachment model. See \code{\link[igraph:sample_pa]{igraph::sample_pa()}}
\item \code{play_barabasi_albert_aging}: Create graphs based on the Barabasi-Alberts
preferential attachment model, incoorporating node age preferrence. See
\code{\link[igraph:sample_pa_age]{igraph::sample_pa_age()}}.
}}
\examples{
plot(play_forestfire(50, 0.5))
}
\seealso{
\code{\link[=play_traits]{play_traits()}} and \code{\link[=play_citation_type]{play_citation_type()}} for an evolutionary
algorithm based on different node types
Other graph games:
\code{\link{component_games}},
\code{\link{sampling_games}},
\code{\link{type_games}}
}
\concept{graph games}
tidygraph/man/mutate_as_tbl.Rd 0000644 0001762 0000144 00000001767 13545322217 016151 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mutate.R
\name{mutate_as_tbl}
\alias{mutate_as_tbl}
\title{Base implementation of mutate}
\usage{
mutate_as_tbl(.data, ...)
}
\arguments{
\item{.data}{A \code{tbl_graph} object}
\item{...}{columns to mutate}
}
\value{
A \code{tbl_graph} object
}
\description{
This implementation of mutate is slightly faster than \code{mutate} at the expense
of the graph only being updated in the end. This means that graph algorithms
will not take changes happening during the mutate call into account.
}
\details{
The order of speed increase are rather small and in the ~1 millisecond per
mutateed column order, so for regular use this should not be a choice. The
operations not supported by \code{mutate_as_tbl} are e.g.\preformatted{gr \%>\%
activate(nodes) \%>\%
mutate(weights = runif(10), degree = centrality_degree(weights))
}
as \code{weights} will only be made available in the graph at the end of the
mutate call.
}
\keyword{internal}
tidygraph/man/tidygraph-package.Rd 0000644 0001762 0000144 00000002017 13654774463 016716 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tidygraph-package.R
\docType{package}
\name{tidygraph-package}
\alias{tidygraph}
\alias{tidygraph-package}
\title{tidygraph: A Tidy API for Graph Manipulation}
\description{
\if{html}{\figure{logo.png}{options: align='right' alt='logo' width='120'}}
A graph, while not "tidy" in itself, can be thought of as two tidy
data frames describing node and edge data respectively. 'tidygraph'
provides an approach to manipulate these two virtual data frames using the
API defined in the 'dplyr' package, as well as provides tidy interfaces to
a lot of common graph algorithms.
}
\seealso{
Useful links:
\itemize{
\item \url{https://tidygraph.data-imaginist.com}
\item \url{https://github.com/thomasp85/tidygraph}
\item Report bugs at \url{https://github.com/thomasp85/tidygraph/issues}
}
}
\author{
\strong{Maintainer}: Thomas Lin Pedersen \email{thomasp85@gmail.com} (\href{https://orcid.org/0000-0002-5147-4711}{ORCID})
}
\keyword{internal}
tidygraph/man/map_bfs_back.Rd 0000644 0001762 0000144 00000007114 13654774463 015724 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/map.R
\name{map_bfs_back}
\alias{map_bfs_back}
\alias{map_bfs_back_lgl}
\alias{map_bfs_back_chr}
\alias{map_bfs_back_int}
\alias{map_bfs_back_dbl}
\title{Apply a function to nodes in the reverse order of a breath first search}
\usage{
map_bfs_back(root, mode = "out", unreachable = FALSE, .f, ...)
map_bfs_back_lgl(root, mode = "out", unreachable = FALSE, .f, ...)
map_bfs_back_chr(root, mode = "out", unreachable = FALSE, .f, ...)
map_bfs_back_int(root, mode = "out", unreachable = FALSE, .f, ...)
map_bfs_back_dbl(root, mode = "out", unreachable = FALSE, .f, ...)
}
\arguments{
\item{root}{The node to start the search from}
\item{mode}{How should edges be followed? \code{'out'} only follows outbound
edges, \code{'in'} only follows inbound edges, and \code{'all'} follows all edges. This
parameter is ignored for undirected graphs.}
\item{unreachable}{Should the search jump to an unvisited node if the search
is completed without visiting all nodes.}
\item{.f}{A function to map over all nodes. See Details}
\item{...}{Additional parameters to pass to \code{.f}}
}
\value{
\code{map_bfs_back()} returns a list of the same length as the number of
nodes in the graph, in the order matching the node order in the graph (that
is, not in the order they are called). \verb{map_bfs_back_*()} tries to coerce
its result into a vector of the classes \code{logical} (\code{map_bfs_back_lgl}),
\code{character} (\code{map_bfs_back_chr}), \code{integer} (\code{map_bfs_back_int}), or \code{double}
(\code{map_bfs_back_dbl}). These functions will throw an error if they are
unsuccesful, so they are type safe.
}
\description{
These functions allow you to map over the nodes in a graph, by first
performing a breath first search on the graph and then mapping over each
node in the reverse order they are visited. The mapping function will have
access to the result and search statistics for all the nodes following itself
in the search. To map over the nodes in the original direction use
\code{\link[=map_bfs]{map_bfs()}}.
}
\details{
The function provided to \code{.f} will be called with the following arguments in
addition to those supplied through \code{...}:
\itemize{
\item \code{graph}: The full \code{tbl_graph} object
\item \code{node}: The index of the node currently mapped over
\item \code{rank}: The rank of the node in the search
\item \code{parent}: The index of the node that led to the current node
\item \code{before}: The index of the node that was visited before the current node
\item \code{after}: The index of the node that was visited after the current node.
\item \code{dist}: The distance of the current node from the root
\item \code{path}: A table containing \code{node}, \code{rank}, \code{parent}, \code{before}, \code{after},
\code{dist}, and \code{result} columns giving the values for each node reached from
the current node. The \code{result} column will contain the result of the mapping
of each node in a list.
}
Instead of spelling out all of these in the function it is possible to simply
name the ones needed and use \code{...} to catch the rest.
}
\examples{
# Collect values from children
create_tree(40, children = 3, directed = TRUE) \%>\%
mutate(value = round(runif(40)*100)) \%>\%
mutate(child_acc = map_bfs_back_dbl(node_is_root(), .f = function(node, path, ...) {
if (nrow(path) == 0) .N()$value[node]
else {
sum(unlist(path$result[path$parent == node]))
}
}))
}
\seealso{
Other node map functions:
\code{\link{map_bfs}()},
\code{\link{map_dfs_back}()},
\code{\link{map_dfs}()}
}
\concept{node map functions}
tidygraph/man/map_dfs.Rd 0000644 0001762 0000144 00000006551 13654774463 014752 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/map.R
\name{map_dfs}
\alias{map_dfs}
\alias{map_dfs_lgl}
\alias{map_dfs_chr}
\alias{map_dfs_int}
\alias{map_dfs_dbl}
\title{Apply a function to nodes in the order of a depth first search}
\usage{
map_dfs(root, mode = "out", unreachable = FALSE, .f, ...)
map_dfs_lgl(root, mode = "out", unreachable = FALSE, .f, ...)
map_dfs_chr(root, mode = "out", unreachable = FALSE, .f, ...)
map_dfs_int(root, mode = "out", unreachable = FALSE, .f, ...)
map_dfs_dbl(root, mode = "out", unreachable = FALSE, .f, ...)
}
\arguments{
\item{root}{The node to start the search from}
\item{mode}{How should edges be followed? \code{'out'} only follows outbound
edges, \code{'in'} only follows inbound edges, and \code{'all'} follows all edges. This
parameter is ignored for undirected graphs.}
\item{unreachable}{Should the search jump to an unvisited node if the search
is completed without visiting all nodes.}
\item{.f}{A function to map over all nodes. See Details}
\item{...}{Additional parameters to pass to \code{.f}}
}
\value{
\code{map_dfs()} returns a list of the same length as the number of nodes
in the graph, in the order matching the node order in the graph (that is, not
in the order they are called). \verb{map_dfs_*()} tries to coerce its result into
a vector of the classes \code{logical} (\code{map_dfs_lgl}), \code{character}
(\code{map_dfs_chr}), \code{integer} (\code{map_dfs_int}), or \code{double} (\code{map_dfs_dbl}).
These functions will throw an error if they are unsuccesful, so they are type
safe.
}
\description{
These functions allow you to map over the nodes in a graph, by first
performing a depth first search on the graph and then mapping over each
node in the order they are visited. The mapping function will have access to
the result and search statistics for all the nodes between itself and the
root in the search. To map over the nodes in the reverse direction use
\code{\link[=map_dfs_back]{map_dfs_back()}}.
}
\details{
The function provided to \code{.f} will be called with the following arguments in
addition to those supplied through \code{...}:
\itemize{
\item \code{graph}: The full \code{tbl_graph} object
\item \code{node}: The index of the node currently mapped over
\item \code{rank}: The rank of the node in the search
\item \code{rank_out}: The rank of the completion of the nodes subtree
\item \code{parent}: The index of the node that led to the current node
\item \code{dist}: The distance of the current node from the root
\item \code{path}: A table containing \code{node}, \code{rank}, \code{rank_out}, \code{parent}, dist\verb{, and }result\verb{columns giving the values for each node leading to the current node. The}result` column will contain the result of the mapping
of each node in a list.
}
Instead of spelling out all of these in the function it is possible to simply
name the ones needed and use \code{...} to catch the rest.
}
\examples{
# Add a random integer to the last value along a search
create_tree(40, children = 3, directed = TRUE) \%>\%
mutate(child_acc = map_dfs_int(node_is_root(), .f = function(node, path, ...) {
last_val <- if (nrow(path) == 0) 0L else tail(unlist(path$result), 1)
last_val + sample(1:10, 1)
}))
}
\seealso{
Other node map functions:
\code{\link{map_bfs_back}()},
\code{\link{map_bfs}()},
\code{\link{map_dfs_back}()}
}
\concept{node map functions}
tidygraph/man/map_dfs_back.Rd 0000644 0001762 0000144 00000006775 13654774463 015742 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/map.R
\name{map_dfs_back}
\alias{map_dfs_back}
\alias{map_dfs_back_lgl}
\alias{map_dfs_back_chr}
\alias{map_dfs_back_int}
\alias{map_dfs_back_dbl}
\title{Apply a function to nodes in the reverse order of a depth first search}
\usage{
map_dfs_back(root, mode = "out", unreachable = FALSE, .f, ...)
map_dfs_back_lgl(root, mode = "out", unreachable = FALSE, .f, ...)
map_dfs_back_chr(root, mode = "out", unreachable = FALSE, .f, ...)
map_dfs_back_int(root, mode = "out", unreachable = FALSE, .f, ...)
map_dfs_back_dbl(root, mode = "out", unreachable = FALSE, .f, ...)
}
\arguments{
\item{root}{The node to start the search from}
\item{mode}{How should edges be followed? \code{'out'} only follows outbound
edges, \code{'in'} only follows inbound edges, and \code{'all'} follows all edges. This
parameter is ignored for undirected graphs.}
\item{unreachable}{Should the search jump to an unvisited node if the search
is completed without visiting all nodes.}
\item{.f}{A function to map over all nodes. See Details}
\item{...}{Additional parameters to pass to \code{.f}}
}
\value{
\code{map_dfs_back()} returns a list of the same length as the number of
nodes in the graph, in the order matching the node order in the graph (that
is, not in the order they are called). \verb{map_dfs_back_*()} tries to coerce
its result into a vector of the classes \code{logical} (\code{map_dfs_back_lgl}),
\code{character} (\code{map_dfs_back_chr}), \code{integer} (\code{map_dfs_back_int}), or \code{double}
(\code{map_dfs_back_dbl}). These functions will throw an error if they are
unsuccesful, so they are type safe.
}
\description{
These functions allow you to map over the nodes in a graph, by first
performing a depth first search on the graph and then mapping over each
node in the reverse order they are visited. The mapping function will have
access to the result and search statistics for all the nodes following itself
in the search. To map over the nodes in the original direction use
\code{\link[=map_dfs]{map_dfs()}}.
}
\details{
The function provided to \code{.f} will be called with the following arguments in
addition to those supplied through \code{...}:
\itemize{
\item \code{graph}: The full \code{tbl_graph} object
\item \code{node}: The index of the node currently mapped over
\item \code{rank}: The rank of the node in the search
\item \code{rank_out}: The rank of the completion of the nodes subtree
\item \code{parent}: The index of the node that led to the current node
\item \code{dist}: The distance of the current node from the root
\item \code{path}: A table containing \code{node}, \code{rank}, \code{rank_out}, \code{parent}, dist\verb{, and }result\verb{columns giving the values for each node reached from the current node. The}result` column will contain the result of the mapping
of each node in a list.
}
Instead of spelling out all of these in the function it is possible to simply
name the ones needed and use \code{...} to catch the rest.
}
\examples{
# Collect values from the 2 closest layers of children in a dfs search
create_tree(40, children = 3, directed = TRUE) \%>\%
mutate(value = round(runif(40)*100)) \%>\%
mutate(child_acc = map_dfs_back(node_is_root(), .f = function(node, path, dist, ...) {
if (nrow(path) == 0) .N()$value[node]
else {
unlist(path$result[path$dist - dist <= 2])
}
}))
}
\seealso{
Other node map functions:
\code{\link{map_bfs_back}()},
\code{\link{map_bfs}()},
\code{\link{map_dfs}()}
}
\concept{node map functions}
tidygraph/man/activate.Rd 0000644 0001762 0000144 00000003162 13654774463 015134 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/activate.R
\name{activate}
\alias{activate}
\alias{active}
\alias{\%N>\%}
\alias{\%E>\%}
\title{Determine the context of subsequent manipulations}
\usage{
activate(.data, what)
active(x)
lhs \%N>\% rhs
lhs \%E>\% rhs
}
\arguments{
\item{.data, x, lhs}{A tbl_graph or a grouped_tbl_graph}
\item{what}{What should get activated? Possible values are \code{nodes} or
\code{edges}.}
\item{rhs}{A function to pipe into}
}
\value{
A tbl_graph
}
\description{
As a \link{tbl_graph} can be considered as a collection of two linked tables it is
necessary to specify which table is referenced during manipulations. The
\code{activate} verb does just that and needs affects all subsequent manipulations
until a new table is activated. \code{active} is a simple query function to get
the currently acitve context. In addition to the use of \code{activate} it is also
possible to activate nodes or edges as part of the piping using the \verb{\%N>\%}
and \verb{\%E>\%} pipes respectively. Do note that this approach somewhat obscures
what is going on and is thus only recommended for quick, one-line, fixes in
interactive use.
}
\note{
Activate will ungroup a grouped_tbl_graph.
}
\examples{
gr <- create_complete(5) \%>\%
activate(nodes) \%>\%
mutate(class = sample(c('a', 'b'), 5, TRUE)) \%>\%
activate(edges) \%>\%
arrange(from)
# The above could be achieved using the special pipes as well
gr <- create_complete(5) \%N>\%
mutate(class = sample(c('a', 'b'), 5, TRUE)) \%E>\%
arrange(from)
# But as you can see it obscures what part of the graph is being targeted
}
tidygraph/man/type_games.Rd 0000644 0001762 0000144 00000006522 13654774463 015474 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/play.R
\name{type_games}
\alias{type_games}
\alias{play_preference}
\alias{play_preference_asym}
\alias{play_bipartite}
\alias{play_traits}
\alias{play_citation_type}
\title{Graph games based on different node types}
\usage{
play_preference(
n,
n_types,
p_type = rep(1, n_types),
p_pref = matrix(1, n_types, n_types),
fixed = FALSE,
directed = TRUE,
loops = FALSE
)
play_preference_asym(
n,
n_types,
p_type = matrix(1, n_types, n_types),
p_pref = matrix(1, n_types, n_types),
loops = FALSE
)
play_bipartite(n1, n2, p, m, directed = TRUE, mode = "out")
play_traits(
n,
n_types,
growth = 1,
p_type = rep(1, n_types),
p_pref = matrix(1, n_types, n_types),
callaway = TRUE,
directed = TRUE
)
play_citation_type(
n,
growth,
types = rep(0, n),
p_pref = rep(1, length(unique(types))),
directed = TRUE
)
}
\arguments{
\item{n, n1, n2}{The number of nodes in the graph. For bipartite graphs \code{n1}
and \code{n2} specifies the number of nodes of each type.}
\item{n_types}{The number of different node types in the graph}
\item{p_type}{The probability that a node will be the given type. Either a
vector or a matrix, depending on the game}
\item{p_pref}{The probability that an edge will be made to a type. Either a
vector or a matrix, depending on the game}
\item{fixed}{Should n_types be understood as a fixed number of nodes for each
type rather than as a probability}
\item{directed}{Should the resulting graph be directed}
\item{loops}{Are loop edges allowed}
\item{p}{The probabilty of an edge occuring}
\item{m}{The number of edges in the graph}
\item{mode}{The flow direction of edges}
\item{growth}{The number of edges added at each iteration}
\item{callaway}{Use the callaway version of the trait based game}
\item{types}{The type of each node in the graph, enumerated from 0}
}
\value{
A tbl_graph object
}
\description{
This set of games are build around different types of nodes and simulating
their interaction. The nature of their algorithm is described in
detail at the linked igraph documentation.
}
\section{Functions}{
\itemize{
\item \code{play_preference}: Create graphs by linking nodes of different types
based on a defined probability. See \code{\link[igraph:sample_pref]{igraph::sample_pref()}}
\item \code{play_preference_asym}: Create graphs by linking nodes of different types
based on an asymmetric probability. See \code{\link[igraph:sample_asym_pref]{igraph::sample_asym_pref()}}
\item \code{play_bipartite}: Create bipartite graphs of fixed size and edge count
or probability. See \code{\link[igraph:sample_bipartite]{igraph::sample_bipartite()}}
\item \code{play_traits}: Create graphs by evolving a graph with type based edge
probabilities. See \code{\link[igraph:sample_traits]{igraph::sample_traits()}} and
\code{\link[igraph:sample_traits_callaway]{igraph::sample_traits_callaway()}}
\item \code{play_citation_type}: Create citation graphs by evolving with type based
linking probability. See \code{\link[igraph:sample_cit_types]{igraph::sample_cit_types()}} and
\code{\link[igraph:sample_cit_cit_types]{igraph::sample_cit_cit_types()}}
}}
\examples{
plot(play_bipartite(20, 30, 0.4))
}
\seealso{
Other graph games:
\code{\link{component_games}},
\code{\link{evolution_games}},
\code{\link{sampling_games}}
}
\concept{graph games}
tidygraph/man/centrality.Rd 0000644 0001762 0000144 00000023155 13654774463 015516 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/centrality.R
\name{centrality}
\alias{centrality}
\alias{centrality_alpha}
\alias{centrality_authority}
\alias{centrality_betweenness}
\alias{centrality_power}
\alias{centrality_closeness}
\alias{centrality_eigen}
\alias{centrality_hub}
\alias{centrality_pagerank}
\alias{centrality_subgraph}
\alias{centrality_degree}
\alias{centrality_edge_betweenness}
\alias{centrality_manual}
\alias{centrality_closeness_harmonic}
\alias{centrality_closeness_residual}
\alias{centrality_closeness_generalised}
\alias{centrality_integration}
\alias{centrality_communicability}
\alias{centrality_communicability_odd}
\alias{centrality_communicability_even}
\alias{centrality_subgraph_odd}
\alias{centrality_subgraph_even}
\alias{centrality_katz}
\alias{centrality_betweenness_network}
\alias{centrality_betweenness_current}
\alias{centrality_betweenness_communicability}
\alias{centrality_betweenness_rsp_simple}
\alias{centrality_betweenness_rsp_net}
\alias{centrality_information}
\alias{centrality_decay}
\alias{centrality_random_walk}
\alias{centrality_expected}
\title{Calculate node and edge centrality}
\usage{
centrality_alpha(
weights = NULL,
alpha = 1,
exo = 1,
tol = 1e-07,
loops = FALSE
)
centrality_authority(
weights = NULL,
scale = TRUE,
options = igraph::arpack_defaults
)
centrality_betweenness(
weights = NULL,
directed = TRUE,
cutoff = NULL,
nobigint = TRUE,
normalized = FALSE
)
centrality_power(exponent = 1, rescale = FALSE, tol = 1e-07, loops = FALSE)
centrality_closeness(
weights = NULL,
mode = "out",
normalized = FALSE,
cutoff = NULL
)
centrality_eigen(
weights = NULL,
directed = FALSE,
scale = TRUE,
options = igraph::arpack_defaults
)
centrality_hub(weights = NULL, scale = TRUE, options = igraph::arpack_defaults)
centrality_pagerank(
weights = NULL,
directed = TRUE,
damping = 0.85,
personalized = NULL
)
centrality_subgraph(loops = FALSE)
centrality_degree(
weights = NULL,
mode = "out",
loops = TRUE,
normalized = FALSE
)
centrality_edge_betweenness(weights = NULL, directed = TRUE, cutoff = NULL)
centrality_manual(relation = "dist_sp", aggregation = "sum", ...)
centrality_closeness_harmonic()
centrality_closeness_residual()
centrality_closeness_generalised(alpha)
centrality_integration()
centrality_communicability()
centrality_communicability_odd()
centrality_communicability_even()
centrality_subgraph_odd()
centrality_subgraph_even()
centrality_katz(alpha = NULL)
centrality_betweenness_network(netflowmode = "raw")
centrality_betweenness_current()
centrality_betweenness_communicability()
centrality_betweenness_rsp_simple(rspxparam = 1)
centrality_betweenness_rsp_net(rspxparam = 1)
centrality_information()
centrality_decay(alpha = 1)
centrality_random_walk()
centrality_expected()
}
\arguments{
\item{weights}{The weight of the edges to use for the calculation. Will be
evaluated in the context of the edge data.}
\item{alpha}{Relative importance of endogenous vs exogenous factors (\code{centrality_alpha}), the exponent to the power transformation of the distance metric (\code{centrality_closeness_generalised}), the base of power transformation (\code{centrality_decay}), or the attenuation factor (\code{centrality_katz})}
\item{exo}{The exogenous factors of the nodes. Either a scalar or a number
number for each node. Evaluated in the context of the node data.}
\item{tol}{Tolerance for near-singularities during matrix inversion}
\item{loops}{Should loops be included in the calculation}
\item{scale}{Should the output be scaled between 0 and 1}
\item{options}{Settings passed on to \code{igraph::arpack()}}
\item{directed}{Should direction of edges be used for the calculations}
\item{cutoff}{maximum path length to use during calculations}
\item{nobigint}{Should big integers be avoided during calculations}
\item{normalized}{Should the output be normalized}
\item{exponent}{The decay rate for the Bonacich power centrality}
\item{rescale}{Should the output be scaled to sum up to 1}
\item{mode}{How should edges be followed. Ignored for undirected graphs}
\item{damping}{The damping factor of the page rank algorithm}
\item{personalized}{The probability of jumping to a node when abandoning a
random walk. Evaluated in the context of the node data.}
\item{relation}{The indirect relation measure type to be used in \code{netrankr::indirect_relations}}
\item{aggregation}{The aggregation type to use on the indirect relations to be used in \code{netrankr::aggregate_positions}}
\item{...}{Arguments to pass on to \code{netrankr::indirect_relations}}
\item{netflowmode}{The return type of the network flow distance, either \code{'raw'} or \code{'frac'}}
\item{rspxparam}{inverse temperature parameter}
}
\value{
A numeric vector giving the centrality measure of each node.
}
\description{
The centrality of a node measures the importance of node in the network. As
the concept of importance is ill-defined and dependent on the network and
the questions under consideration, many centrality measures exist.
\code{tidygraph} provides a consistent set of wrappers for all the centrality
measures implemented in \code{igraph} for use inside \code{\link[dplyr:mutate]{dplyr::mutate()}} and other
relevant verbs. All functions provided by \code{tidygraph} have a consistent
naming scheme and automatically calls the function on the graph, returning a
vector with measures ready to be added to the node data. Further \code{tidygraph}
provides access to the \code{netrankr} engine for centrality calculations and
define a number of centrality measures based on that, as well as provide a
manual mode for specifying more-or-less any centrality score.
}
\section{Functions}{
\itemize{
\item \code{centrality_alpha}: Wrapper for \code{\link[igraph:alpha_centrality]{igraph::alpha_centrality()}}
\item \code{centrality_authority}: Wrapper for \code{\link[igraph:authority_score]{igraph::authority_score()}}
\item \code{centrality_betweenness}: Wrapper for \code{\link[igraph:betweenness]{igraph::betweenness()}} and \code{\link[igraph:estimate_betweenness]{igraph::estimate_betweenness()}}
\item \code{centrality_power}: Wrapper for \code{\link[igraph:power_centrality]{igraph::power_centrality()}}
\item \code{centrality_closeness}: Wrapper for \code{\link[igraph:closeness]{igraph::closeness()}} and \code{\link[igraph:estimate_closeness]{igraph::estimate_closeness()}}
\item \code{centrality_eigen}: Wrapper for \code{\link[igraph:eigen_centrality]{igraph::eigen_centrality()}}
\item \code{centrality_hub}: Wrapper for \code{\link[igraph:hub_score]{igraph::hub_score()}}
\item \code{centrality_pagerank}: Wrapper for \code{\link[igraph:page_rank]{igraph::page_rank()}}
\item \code{centrality_subgraph}: Wrapper for \code{\link[igraph:subgraph_centrality]{igraph::subgraph_centrality()}}
\item \code{centrality_degree}: Wrapper for \code{\link[igraph:degree]{igraph::degree()}} and \code{\link[igraph:strength]{igraph::strength()}}
\item \code{centrality_edge_betweenness}: Wrapper for \code{\link[igraph:edge_betweenness]{igraph::edge_betweenness()}}
\item \code{centrality_manual}: Manually specify your centrality score using the \code{netrankr} framework (\code{netrankr})
\item \code{centrality_closeness_harmonic}: centrality based on inverse shortest path (\code{netrankr})
\item \code{centrality_closeness_residual}: centrality based on 2-to-the-power-of negative shortest path (\code{netrankr})
\item \code{centrality_closeness_generalised}: centrality based on alpha-to-the-power-of negative shortest path (\code{netrankr})
\item \code{centrality_integration}: centrality based on \eqn{1 - (x - 1)/max(x)} transformation of shortest path (\code{netrankr})
\item \code{centrality_communicability}: centrality an exponential tranformation of walk counts (\code{netrankr})
\item \code{centrality_communicability_odd}: centrality an exponential tranformation of odd walk counts (\code{netrankr})
\item \code{centrality_communicability_even}: centrality an exponential tranformation of even walk counts (\code{netrankr})
\item \code{centrality_subgraph_odd}: subgraph centrality based on odd walk counts (\code{netrankr})
\item \code{centrality_subgraph_even}: subgraph centrality based on even walk counts (\code{netrankr})
\item \code{centrality_katz}: centrality based on walks penalizing distant nodes (\code{netrankr})
\item \code{centrality_betweenness_network}: Betweenness centrality based on network flow (\code{netrankr})
\item \code{centrality_betweenness_current}: Betweenness centrality based on current flow (\code{netrankr})
\item \code{centrality_betweenness_communicability}: Betweenness centrality based on communicability (\code{netrankr})
\item \code{centrality_betweenness_rsp_simple}: Betweenness centrality based on simple randomised shortest path dependencies (\code{netrankr})
\item \code{centrality_betweenness_rsp_net}: Betweenness centrality based on net randomised shortest path dependencies (\code{netrankr})
\item \code{centrality_information}: centrality based on inverse sum of resistance distance between nodes (\code{netrankr})
\item \code{centrality_decay}: based on a power transformation of the shortest path (\code{netrankr})
\item \code{centrality_random_walk}: centrality based on the inverse sum of expected random walk length between nodes (\code{netrankr})
\item \code{centrality_expected}: Expected centrality ranking based on exact rank probability (\code{netrankr})
}}
\examples{
create_notable('bull') \%>\%
activate(nodes) \%>\%
mutate(importance = centrality_alpha())
# Most centrality measures are for nodes but not all
create_notable('bull') \%>\%
activate(edges) \%>\%
mutate(importance = centrality_edge_betweenness())
}
tidygraph/man/tbl_graph.Rd 0000644 0001762 0000144 00000013203 13656212072 015254 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data_frame.R, R/data_tree.R, R/dendrogram.R,
% R/graph.R, R/hclust.R, R/igraph.R, R/list.R, R/matrix.R, R/network.R,
% R/phylo.R, R/tbl_graph.R
\name{as_tbl_graph.data.frame}
\alias{as_tbl_graph.data.frame}
\alias{as_tbl_graph.Node}
\alias{as_tbl_graph.dendrogram}
\alias{as_tbl_graph.graphNEL}
\alias{as_tbl_graph.graphAM}
\alias{as_tbl_graph.graphBAM}
\alias{as_tbl_graph.hclust}
\alias{as_tbl_graph.igraph}
\alias{as_tbl_graph.list}
\alias{as_tbl_graph.matrix}
\alias{as_tbl_graph.network}
\alias{as_tbl_graph.phylo}
\alias{as_tbl_graph.evonet}
\alias{tbl_graph}
\alias{as_tbl_graph}
\alias{as_tbl_graph.default}
\alias{is.tbl_graph}
\title{A data structure for tidy graph manipulation}
\usage{
\method{as_tbl_graph}{data.frame}(x, directed = TRUE, ...)
\method{as_tbl_graph}{Node}(x, directed = TRUE, mode = "out", ...)
\method{as_tbl_graph}{dendrogram}(x, directed = TRUE, mode = "out", ...)
\method{as_tbl_graph}{graphNEL}(x, ...)
\method{as_tbl_graph}{graphAM}(x, ...)
\method{as_tbl_graph}{graphBAM}(x, ...)
\method{as_tbl_graph}{hclust}(x, directed = TRUE, mode = "out", ...)
\method{as_tbl_graph}{igraph}(x, ...)
\method{as_tbl_graph}{list}(x, directed = TRUE, node_key = "name", ...)
\method{as_tbl_graph}{matrix}(x, directed = TRUE, ...)
\method{as_tbl_graph}{network}(x, ...)
\method{as_tbl_graph}{phylo}(x, directed = NULL, ...)
\method{as_tbl_graph}{evonet}(x, directed = TRUE, ...)
tbl_graph(nodes = NULL, edges = NULL, directed = TRUE, node_key = "name")
as_tbl_graph(x, ...)
\method{as_tbl_graph}{default}(x, ...)
is.tbl_graph(x)
}
\arguments{
\item{x}{An object convertible to a \code{tbl_graph}}
\item{directed}{Should the constructed graph be directed (defaults to \code{TRUE})}
\item{...}{Arguments passed on to the conversion function}
\item{mode}{In case \code{directed = TRUE} should the edge direction be away from
node or towards. Possible values are \code{"out"} (default) or \code{"in"}.}
\item{node_key}{The name of the column in \code{nodes} that character represented
\code{to} and \code{from} columns should be matched against. If \code{NA} the first column
is always chosen. This setting has no effect if \code{to} and \code{from} are given as
integers.}
\item{nodes}{A \code{data.frame} containing information about the nodes in the
graph. If \code{edges$to} and/or \code{edges$from} are characters then they will be
matched to the column named according to \code{node_key} in nodes, if it exists.
If not, they will be matched to the first column.}
\item{edges}{A \code{data.frame} containing information about the edges in the
graph. The terminal nodes of each edge must either be encoded in a \code{to} and
\code{from} column, or in the two first columns, as integers. These integers refer to
\code{nodes} index.}
}
\value{
A \code{tbl_graph} object
}
\description{
The \code{tbl_graph} class is a thin wrapper around an \code{igraph} object that
provides methods for manipulating the graph using the tidy API. As it is just
a subclass of \code{igraph} every igraph method will work as expected. A
\code{grouped_tbl_graph} is the equivalent of a \code{grouped_df} where either the
nodes or the edges has been grouped. The \code{grouped_tbl_graph} is not
constructed directly but by using the \code{\link[=group_by]{group_by()}} verb. After creation of a
\code{tbl_graph} the nodes are activated by default. The context can be changed
using the \code{\link[=activate]{activate()}} verb and affects all subsequent operations. Changing
context automatically drops any grouping. The current active context can
always be extracted with \code{\link[=as_tibble]{as_tibble()}}, which drops the graph structure and
just returns a \code{tbl_df} or a \code{grouped_df} depending on the state of the
\code{tbl_graph}. The returned context can be overriden by using the \code{active}
argument in \code{\link[=as_tibble]{as_tibble()}}.
}
\details{
Constructors are provided for most data structures that resembles networks.
If a class provides an \code{\link[igraph:as.igraph]{igraph::as.igraph()}} method it is automatically
supported.
}
\section{Methods (by generic)}{
\itemize{
\item \code{as_tbl_graph}: Method for edge table and set membership table
\item \code{as_tbl_graph}: Method to deal with Node objects from the data.tree package
\item \code{as_tbl_graph}: Method for dendrogram objects
\item \code{as_tbl_graph}: Method for handling graphNEL objects from the graph package (on Bioconductor)
\item \code{as_tbl_graph}: Method for handling graphAM objects from the graph package (on Bioconductor)
\item \code{as_tbl_graph}: Method for handling graphBAM objects from the graph package (on Bioconductor)
\item \code{as_tbl_graph}: Method for hclust objects
\item \code{as_tbl_graph}: Method for igraph object. Simply subclasses the object into a \code{tbl_graph}
\item \code{as_tbl_graph}: Method for adjacency lists and lists of node and edge tables
\item \code{as_tbl_graph}: Method for edgelist, adjacency and incidence matrices
\item \code{as_tbl_graph}: Method to handle network objects from the \code{network}
package. Requires this packages to work.
\item \code{as_tbl_graph}: Method for handling phylo objects from the ape package
\item \code{as_tbl_graph}: Method for handling evonet objects from the ape package
\item \code{as_tbl_graph}: Default method. tries to call \code{\link[igraph:as.igraph]{igraph::as.igraph()}} on the input.
}}
\examples{
rstat_nodes <- data.frame(name = c("Hadley", "David", "Romain", "Julia"))
rstat_edges <- data.frame(from = c(1, 1, 1, 2, 3, 3, 4, 4, 4),
to = c(2, 3, 4, 1, 1, 2, 1, 2, 3))
tbl_graph(nodes = rstat_nodes, edges = rstat_edges)
}
tidygraph/man/figures/ 0000755 0001762 0000144 00000000000 13545322217 014470 5 ustar ligges users tidygraph/man/figures/logo.png 0000644 0001762 0000144 00000061775 13545322217 016156 0 ustar ligges users PNG
IHDR G? iCCPsRGB IEC61966-2.1 (u+DQ?f0#d1i
Qe$4Q7ofx7dl%6~-*kll
zΛI==l6j=߹^t:^hN=n"3T{jxoժ~_k5
£焧gVs;J2>w-ʼn"[`kv&*8ZJROqSyt%jf~Nbx7A&d 1Ȉ>2 +{
d%WYc
$'j^㢫2RYW#>-VoCݳic~L4r~?D*kh݀݅M|"z m8BKoqس>'Z}p_'glx pHYs IDATxwt[ו?A`
%QQj.%ٱ-ۉg7I6JO&yL&ɛIL2qN\cVU-DI zb{Z^^"s.Q~}m2S
%@/p"&lɺrZ`MBh^kBHuɾN}
w Vp pJza2 נ|>g /3yda$5dMM8$U#I