Creating One or Multiple Networks from a List of Nodes and Directed Edges
Source:R/build_dynamic_networks.R
build_dynamic_networks.Rd
build_network()
creates a network from a table of nodes and its
directed edges. That is a special case of the more general build_dynamic_networks()
.
This function creates one or several tibble graphs (built with
tidygraph) from a table of nodes and its
directed edges. For instance, for bibliometric networks, you can give a list of
articles and the list of the references these articles cite. You can use it to
build a single network or multiple networks over different time windows.
Usage
build_dynamic_networks(
nodes,
directed_edges,
source_id,
target_id,
time_variable = NULL,
time_window = NULL,
cooccurrence_method = c("coupling_angle", "coupling_strength", "coupling_similarity"),
overlapping_window = FALSE,
edges_threshold = 1,
compute_size = FALSE,
keep_singleton = FALSE,
filter_components = FALSE,
...,
verbose = TRUE
)
build_network(
nodes,
directed_edges,
source_id,
target_id,
cooccurrence_method = c("coupling_angle", "coupling_strength", "coupling_similarity"),
edges_threshold = 1,
compute_size = FALSE,
keep_singleton = FALSE,
filter_components = FALSE,
...
)
Arguments
- nodes
The table with all the nodes and their metadata. For instance, if your nodes are articles, this table is likely to contain the year of publication, the name of the authors, the title of the article, etc... The table must have one row per node.
- directed_edges
The table with of all the elements to which your nodes are connected. If your nodes are articles, the
directed_edges
table can contain the list of the references cited by these articles, the authors that have written these articles, or the affiliations of the authors of these articles.- source_id
The quoted name of the column with the unique identifier of each node. For instance, for a bibliographic coupling network, the id of your citing documents. It corresponds to the
source
argument of biblionetwork functions.- target_id
The quoted name of the column with the unique identifier of each element connected to the node (for instance, the identifier of the reference cited by your node if the node is an article). It corresponds to the
ref
argument of biblionetwork functions.- time_variable
The column with the temporal variable you want to use to build your windows for the succession of networks. By default,
time_variable
isNULL
and the function will only build one network without taking into account any temporal variable.- time_window
The length of your network relatively of the unity of the
time_variable
column. If you use a variable in years astime_variable
and you settime_window
at 5, the function will build network on five year windows. By default,time_window
isNULL
and the function will only build one network.- cooccurrence_method
Choose a cooccurrence method to build your indirect edges table. The function propose three methods that depends on the biblionetwork package and three methods that are implemented in it:
the coupling angle measure (see
biblionetwork::biblio_coupling()
for documentation);the coupling strength measure (
biblionetwork::coupling_strength()
);the coupling similarity measure (
biblionetwork:: coupling_similarity()
).
- overlapping_window
Set to
FALSE
by default. If set toTRUE
, and iftime_variable
andtime_window
notNULL
, the function will create a succession of networks for moving time windows. The windows are moving one unit per one unit of thetime_variable
. For instance, for years, iftime_window
set to 5, it creates networks for successive time windows like 1970-1974, 1971-1975, 1972-1976, etc.- edges_threshold
Threshold value for building your edges. With a higher threshold, only the stronger links will be kept. See the biblionetwork package documentation and the
cooccurrence_method
parameter.- compute_size
Set to
FALSE
by default. IfTRUE
, the function uses thedirected_edges
data to calculate how many directed edges a node receives (as a target). Ifdirected_edges
is a table of direct citations, the functions calculates the number of time a node is cited by the other nodes. You need to have thetarget_id
in thenodes
table to make the link with the targetted nodes in thedirected_edges
table.- keep_singleton
Set to
FALSE
by default. IfTRUE
, the function removes the nodes that have no undirected edges, i.e. no cooccurrence with any other nodes. In graphical terms, these nodes are alone in the network, with no link with other nodes.- filter_components
Set to
TRUE
if you want to runnetworkflow::filter_components()
to filter the components of the network(s) and keep only the biggest component(s). If you don't change the defaults parameters ofnetworkflow::filter_components()
, it will keep only the main component.- ...
Additional arguments from
networkflow::filter_components()
.- verbose
Set to
FALSE
if you don't want the function to display different sort of information.
Value
If time_window
is NULL
, the function computes only
one network and return a tidygraph object built with tbl_graph().
If time_variable
and time_window
are not NULL
, the function returns a list
of tidygraph networks, for each time window.
Details
build_network()
has been added for convenience but it is just
a special case of the more general build_dynamic_networks()
, with
Examples
library(networkflow)
nodes <- Nodes_stagflation |>
dplyr::rename(ID_Art = ItemID_Ref) |>
dplyr::filter(Type == "Stagflation")
references <- Ref_stagflation |>
dplyr::rename(ID_Art = Citing_ItemID_Ref)
temporal_networks <- build_dynamic_networks(nodes = nodes,
directed_edges = references,
source_id = "ID_Art",
target_id = "ItemID_Ref",
time_variable = "Year",
cooccurrence_method = "coupling_similarity",
time_window = 20,
edges_threshold = 1,
overlapping_window = TRUE)
#> ℹ The method use for co-occurence is the coupling_similarity method.
#> ℹ The edge threshold is: 1.
#> ℹ We remove the nodes that are alone with no edge.
#>
#> ── Creation of the network for the 1975-1994 window. ───────────────────────────
#>
#> ── Creation of the network for the 1976-1995 window. ───────────────────────────
#>
#> ── Creation of the network for the 1977-1996 window. ───────────────────────────
#>
#> ── Creation of the network for the 1978-1997 window. ───────────────────────────
#>
#> ── Creation of the network for the 1979-1998 window. ───────────────────────────
#>
#> ── Creation of the network for the 1980-1999 window. ───────────────────────────
#>
#> ── Creation of the network for the 1981-2000 window. ───────────────────────────
#>
#> ── Creation of the network for the 1982-2001 window. ───────────────────────────
#>
#> ── Creation of the network for the 1983-2002 window. ───────────────────────────
#>
#> ── Creation of the network for the 1984-2003 window. ───────────────────────────
#>
#> ── Creation of the network for the 1985-2004 window. ───────────────────────────
#>
#> ── Creation of the network for the 1986-2005 window. ───────────────────────────
#>
#> ── Creation of the network for the 1987-2006 window. ───────────────────────────
#>
#> ── Creation of the network for the 1988-2007 window. ───────────────────────────
#>
#> ── Creation of the network for the 1989-2008 window. ───────────────────────────
#>
#> ── Creation of the network for the 1990-2009 window. ───────────────────────────
#>
#> ── Creation of the network for the 1991-2010 window. ───────────────────────────
#>
#> ── Creation of the network for the 1992-2011 window. ───────────────────────────
#>
#> ── Creation of the network for the 1993-2012 window. ───────────────────────────
#>
#> ── Creation of the network for the 1994-2013 window. ───────────────────────────
temporal_networks[[1]]
#> # A tbl_graph: 74 nodes and 446 edges
#> #
#> # An undirected simple graph with 1 component
#> #
#> # Node Data: 74 × 8 (active)
#> ID_Art Author Year Author_date Title Journal Type time_window
#> <chr> <chr> <int> <chr> <chr> <chr> <chr> <chr>
#> 1 16182155 GORDON-R 1975 GORDON-R-1… ALTE… "BROOK… Stag… 1975-1994
#> 2 26283591 GORDON-R 1975 GORDON-R-1… THE … "BROOK… Stag… 1975-1994
#> 3 16182201 OKUN-A 1975 OKUN-A-197… INFL… "BROOK… Stag… 1975-1994
#> 4 47749045 BRONFENBRENNER-M 1976 BRONFENBRE… ELEM… "ZEITS… Stag… 1975-1994
#> 5 1111111141 KARNOSKY-D 1976 KARNOSKY-D… THE … "REVIE… Stag… 1975-1994
#> 6 1021902 FRIEDMAN-M 1977 FRIEDMAN-M… NOBE… "THE J… Stag… 1975-1994
#> 7 5200398 GOLDSTEIN-M 1977 GOLDSTEIN-… DOWN… "STAFF… Stag… 1975-1994
#> 8 31895842 GORDON-R 1977 GORDON-R-1… CAN … "BROOK… Stag… 1975-1994
#> 9 14371908 RASCHE-R 1977 RASCHE-R-1… THE … "" Stag… 1975-1994
#> 10 6013999 SHERMAN-H 1977 SHERMAN-H-… MONO… "JOURN… Stag… 1975-1994
#> # ℹ 64 more rows
#> #
#> # Edge Data: 446 × 5
#> from to weight Source Target
#> <int> <int> <dbl> <chr> <chr>
#> 1 6 11 0.00158 1021902 1111111122
#> 2 6 45 0.000173 1021902 1111111128
#> 3 6 66 0.000430 1021902 1111111134
#> # ℹ 443 more rows