graph_to_adjlist: Convert graph into an adjacency list

Description Usage Arguments Value Examples

View source: R/graph_to_adjlist.R

Description

An "adjacency list" is similar to an edgelist, in that every row encodes the relationship between two nodes. However, an edgelist will typically contain only non-zero relationships.

On the other hand, in an adjlist, we are explicitly interested in maintaining a full list of all possible pairwise relationships.

Beware combinatorical explosion for large graphs.

Usage

1
graph_to_adjlist(input_tidygraph)

Arguments

input_tidygraph

A 'tbl_graph' representation from 'tidygraph'. This function will not work with other kinds of network representations, e.g. from 'igraph'. Make sure that your input graph is either directed or undirected, as you'd like it.

Value

A tibble containing as many observations as there are cells in an NxN matrix, where N=number of nodes.

Examples

1
2
3
4
`%>%` <- magrittr::`%>%`
successr::karate %>%
    tidygraph::as_tbl_graph(directed = F) %>%
    graph_to_adjlist()

psychNerdJae/successr documentation built on Dec. 22, 2021, 9:56 a.m.