cograph provides verbs for reshaping a network. Each verb accepts any
supported input (matrix, edge list, igraph, statnet network, tna model,
cograph_network) and takes its options as named arguments. The
result is a cograph_network, or the input format when
keep_format = TRUE. as.data.frame() returns the edge or node
table of a result.
Value
Each verb returns a cograph_network, except
split_components(), which returns a list of them. With
keep_format = TRUE a matrix, igraph, statnet network or tna input
comes back in that format. An edge-list data frame comes back as a
cograph_network with a warning.
Selecting
filter_nodes(),select_nodes()Keep nodes by expression, name, index, top-N, neighborhood or component.
filter_edges(),select_edges()Keep edges by expression, endpoints, bridges, mutuality or top-N.
select_neighbors(),select_component(),select_top(),select_k_core()Named shorthands for the common selections.
split_components()One network per connected component.
Weights
threshold_edges()Keep edges by weight, count, proportion or density.
binarize()Replace weights with 0/1.
symmetrize()Combine opposite arcs into one edge.
normalize_weights()Rescale by row, column, maximum, total, or to [0, 1].
invert_weights()Turn similarities into distances.
Structure
to_undirected(),to_directed(),reverse_edges()Change directedness.
remove_isolates()Drop nodes with no edges.
contract_nodes()Collapse groups of nodes into one.
spanning_tree(),complement_network()Derived graphs.
reorder_nodes(),rename_nodes()Change node order or labels without changing the network.
simplify()Merge duplicate edges and drop loops. It returns the input format.
Editing
add_nodes(),remove_nodes(),add_edges(),remove_edges()Add and remove.
mutate_nodes(),mutate_edges()Compute and store attributes.
bind_networks()Union, intersection or difference of two networks.
Conversion and access
as_cograph(), to_matrix(),
to_igraph(), to_network(),
to_df(), and as.data.frame() on a
cograph_network (see as.data.frame.cograph_network).
Semantics
Filtering edges does not remove nodes, as in
igraph::delete_edges()and tidygraph. Nodes left without edges raise acograph_isolates_createdwarning. They are dropped byremove_isolates()or bykeep_isolates = FALSEin the verbs that have that argument.The weight matrix of an undirected result is symmetric, so the result is still detected as undirected downstream.
Node groups, estimation data, layout coordinates and the original source type are carried through the verbs.
Unknown node names, out-of-range or fractional indices, unknown measure names and a malformed
betweenraise acograph_bad_selectionerror. Thenameargument ofselect_nodes()is an exception. Unknown names in it are skipped, and a warning is given when no node matches.
Related verbs elsewhere
ego_networks(), shortest_paths(),
disparity_filter(), detect_communities(),
summarize_clusters(), aggregate_layers().
Examples
as.data.frame(threshold_edges(regulation_net, minimum = 0.2))
#> from to weight
#> 1 Adapt Explore 0.28
#> 2 Discuss Explore 0.30
#> 3 Share Plan 0.21
#> 4 Evaluate Monitor 0.33
#> 5 Share Monitor 0.49
#> 6 Evaluate Adapt 0.43
#> 7 Share Adapt 0.39
#> 8 Explore Reflect 0.35
#> 9 Discuss Reflect 0.35
#> 10 Synthesize Reflect 0.42
#> 11 Plan Discuss 0.40
#> 12 Adapt Discuss 0.34
#> 13 Plan Evaluate 0.49
#> 14 Create Evaluate 0.39
#> 15 Plan Create 0.20
#> 16 Monitor Create 0.37
#> 17 Explore Share 0.27
#> 18 Plan Share 0.36
#> 19 Create Share 0.23
