diff --git a/DESCRIPTION b/DESCRIPTION index e6515487..08ea11cc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: migraph Title: Tools for Multimodal Network Analysis -Version: 0.11.3 -Date: 2022-09-13 +Version: 0.12.0 +Date: 2022-09-23 Description: A set of tools for analysing multimodal networks. All functions operate with matrices, edge lists, and 'igraph', 'network', and 'tidygraph' objects, diff --git a/NAMESPACE b/NAMESPACE index 479c7a0b..64362a86 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -93,12 +93,16 @@ S3method(plot,graph_test) S3method(plot,matrix) S3method(plot,netlm) S3method(plot,netlogit) +S3method(plot,network_test) S3method(plot,node_measure) S3method(plot,node_member) S3method(plot,tie_measure) S3method(print,graph_measure) S3method(print,graph_motif) S3method(print,graph_test) +S3method(print,network_measure) +S3method(print,network_motif) +S3method(print,network_test) S3method(print,node_mark) S3method(print,node_measure) S3method(print,node_member) @@ -305,7 +309,37 @@ export(layout_tbl_graph_ladder) export(layout_tbl_graph_railway) export(layout_tbl_graph_stressgrid) export(mutate) +export(network_adhesion) +export(network_assortativity) +export(network_balance) +export(network_betweenness) +export(network_closeness) +export(network_cohesion) +export(network_components) +export(network_congruency) +export(network_core) +export(network_degree) +export(network_density) +export(network_diameter) +export(network_dims) +export(network_diversity) +export(network_dyad_census) +export(network_eigenvector) +export(network_equivalency) +export(network_factions) +export(network_homophily) +export(network_length) +export(network_mixed_census) +export(network_modularity) +export(network_node_attributes) +export(network_nodes) +export(network_reciprocity) export(network_reg) +export(network_smallworld) +export(network_tie_attributes) +export(network_ties) +export(network_transitivity) +export(network_triad_census) export(node_attribute) export(node_automorphic_equivalence) export(node_betweenness) diff --git a/NEWS.md b/NEWS.md index 4179a134..5ff58b23 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,921 +1,911 @@ +# migraph 0.12.0 + +## Package + +- `graph_*()` functions now renamed to `network_*()` for terminological consistency +- Added `p2visualization` vignette + - more motivation re Tufte and Brandes et al + - an overview on key multimodal layouts + - a few demonstrations of `{patchwork}` functionality + +# migraph 0.11.4 + +## Package + +- Added igraph/migraph layout comparison to README + # migraph 0.11.3 ## Package -- Fixed CRAN LaTeX issue relating to underscores in manual figures +- Fixed CRAN LaTeX issue relating to underscores in manual figures ## Mapping -- Fixed bug in plotting space coordinates for named two-mode networks -- Suppressed messages relating to 'graph' class being defined by multiple packages +- Fixed bug in plotting space coordinates for named two-mode networks +- Suppressed messages relating to 'graph' class being defined by multiple packages # migraph 0.11.2 ## Package -- Filled in some further documentation -- Dropped some older defunct functions +- Filled in some further documentation +- Dropped some older defunct functions ## Measures -- Renamed `graph_blau_index()` to `graph_diversity()` -- Renamed `graph_ei_index()` to `graph_homophily()` +- Renamed `graph_blau_index()` to `graph_diversity()` +- Renamed `graph_ei_index()` to `graph_homophily()` ## Mapping -- Fixed bug with `autographr()`'s "node_group" argument +- Fixed bug with `autographr()`'s "node_group" argument # migraph 0.11.1 ## Package -- Fixed documentation issues (URLs, equations) +- Fixed documentation issues (URLs, equations) # migraph 0.11.0 ## Package -- Reference and articles tabs on package website now called "Function Overview" and "Practical Lessons" respectively -- Reinstated equivalence and blockmodelling vignettes -- All vignettes now precompiled to avoid CRAN issues +- Reference and articles tabs on package website now called "Function Overview" and "Practical Lessons" respectively +- Reinstated equivalence and blockmodelling vignettes +- All vignettes now precompiled to avoid CRAN issues ## Manipulation -- Added `as_graphAM()` methods for all migraph-consistent object classes so `{Rgraphviz}` can be used effectively -- Added `as_igraph()`, `as_tidygraph()`, and `as_network()` methods for `{RSiena}` sienaData objects (thanks @JaelTan, closed #94) -- Added `as_edgelist()` and `as_matrix()` methods for `network.goldfish` class objects -- The `"twomode"` argument in `as_matrix()` is now `NULL` by default, allowing both one-mode and two-mode coercion -- `to_mode1()` and `to_mode2()` now take an extra argument to produce weighted projections by different "similarity" measures - - "count" (the default) returns a raw count of the coincidence of nodes in the specified mode with nodes of the other mode - - "jaccard" (Jaccard index) offers a measure of opportunity weighted by participation - - "rand" (Simple Matching Coefficient) offers a measure of behavioral mirroring - - "pearson" (Pearson's correlation) and "yule" (Yule's Q) offer correlation coefficients for valued and binary data, respectively - - These options work for edgelists, matrices, igraph and tidygraph, and network objects -- Added `to_matching()` methods to transform a two-mode network or network with some other (binary) "mark" attribute into a network of matching ties -- Renamed `to_main_component()` to `to_giant()` to be more space efficient - - Added methods for edgelists and matrices -- Added two-mode application for `to_blocks()` (closed #242) - - Fixed bug in `to_blocks()` where NA blocks couldn't be subsequently coerced -- Filled in a number of S3 methods - - `to_blocks()`, `to_subgraph()`, and `to_ties()` are now S3 methods, returning objects of the same class as given - - Added `to_onemode()` method for matrices - - Added `to_twomode()` methods for igraph, tidygraph, and network - - Added network methods for `to_named()`, `to_redirected()`, `to_uniplex()`, and `to_unsigned()` - - Added edgelist methods for `to_undirected()` and `to_uniplex()` - - Added matrix method for `to_uniplex()` -- Fixed bug where `to_unweighted()` didn't respect the "threshold" specified +- Added `as_graphAM()` methods for all migraph-consistent object classes so `{Rgraphviz}` can be used effectively +- Added `as_igraph()`, `as_tidygraph()`, and `as_network()` methods for `{RSiena}` sienaData objects (thanks @JaelTan, closed #94) +- Added `as_edgelist()` and `as_matrix()` methods for `network.goldfish` class objects +- The `"twomode"` argument in `as_matrix()` is now `NULL` by default, allowing both one-mode and two-mode coercion +- `to_mode1()` and `to_mode2()` now take an extra argument to produce weighted projections by different "similarity" measures + - "count" (the default) returns a raw count of the coincidence of nodes in the specified mode with nodes of the other mode + - "jaccard" (Jaccard index) offers a measure of opportunity weighted by participation + - "rand" (Simple Matching Coefficient) offers a measure of behavioral mirroring + - "pearson" (Pearson's correlation) and "yule" (Yule's Q) offer correlation coefficients for valued and binary data, respectively + - These options work for edgelists, matrices, igraph and tidygraph, and network objects +- Added `to_matching()` methods to transform a two-mode network or network with some other (binary) "mark" attribute into a network of matching ties +- Renamed `to_main_component()` to `to_giant()` to be more space efficient + - Added methods for edgelists and matrices +- Added two-mode application for `to_blocks()` (closed #242) + - Fixed bug in `to_blocks()` where NA blocks couldn't be subsequently coerced +- Filled in a number of S3 methods + - `to_blocks()`, `to_subgraph()`, and `to_ties()` are now S3 methods, returning objects of the same class as given + - Added `to_onemode()` method for matrices + - Added `to_twomode()` methods for igraph, tidygraph, and network + - Added network methods for `to_named()`, `to_redirected()`, `to_uniplex()`, and `to_unsigned()` + - Added edgelist methods for `to_undirected()` and `to_uniplex()` + - Added matrix method for `to_uniplex()` +- Fixed bug where `to_unweighted()` didn't respect the "threshold" specified ## Marks -- Fixed eternal loop bug where `node_mode()` couldn't produce a "mark" class object -- Fixed bug where node names/labels were not being added to mark objects -- Fixed bug in `is_twomode()` where labelling information was being ignored +- Fixed eternal loop bug where `node_mode()` couldn't produce a "mark" class object +- Fixed bug where node names/labels were not being added to mark objects +- Fixed bug in `is_twomode()` where labelling information was being ignored ## Measures -- `graph_core()` now runs `node_core()` (see below) if no "membership" vector is provided +- `graph_core()` now runs `node_core()` (see below) if no "membership" vector is provided ## Membership -- Added `node_core()` for partitioning nodes into core and periphery memberships -- Fixed floating point bug in `k_strict()` +- Added `node_core()` for partitioning nodes into core and periphery memberships +- Fixed floating point bug in `k_strict()` ## Models -- Added "tertius" effect for `network_reg()` -- "ego" and "alter" effects now work better for two-mode networks in `network_reg()` +- Added "tertius" effect for `network_reg()` +- "ego" and "alter" effects now work better for two-mode networks in `network_reg()` ## Mapping -- Added "hierarchy" and "alluvial" layout methods -- Added "railway" and "ladder" layout methods (closed #125) -- Added "concentric" layout method -- Restructured `autographr()` to improve future debugging and development -- `autographr()` now rotates labels for partitioning layouts, including "concentric", so that they are readable and overlap less -- Fixed `gglineage()` to use "alluvial" layout and better position nodes on the _x_-axis +- Added "hierarchy" and "alluvial" layout methods +- Added "railway" and "ladder" layout methods (closed #125) +- Added "concentric" layout method +- Restructured `autographr()` to improve future debugging and development +- `autographr()` now rotates labels for partitioning layouts, including "concentric", so that they are readable and overlap less +- Fixed `gglineage()` to use "alluvial" layout and better position nodes on the *x*-axis ## Data -- `mpn_cow_igo` now includes "polity2" scores -- Added visualisations to some `ison_` and `mpn_` data documentation (closed #237) +- `mpn_cow_igo` now includes "polity2" scores +- Added visualisations to some `ison_` and `mpn_` data documentation (closed #237) # migraph 0.10.6 ## Package -- Fixed URL error in a vignette +- Fixed URL error in a vignette # migraph 0.10.5 ## Package -- Dropped vignettes for now to ensure package makes it on to CRAN +- Dropped vignettes for now to ensure package makes it on to CRAN # migraph 0.10.4 ## Package -- Fixed some URL issues for CRAN +- Fixed some URL issues for CRAN ## Manipulation -- Split `to_*()` functions into reformatting (changing properties) and transforming (changing dimensions) documentation +- Split `to_*()` functions into reformatting (changing properties) and transforming (changing dimensions) documentation # migraph 0.10.3 ## Package -- Updated the DESCRIPTION and CITATION -- Renamed `edge_*()` to `tie_*()` to offer more (SNA) consistent vocabulary -- Added DOIs to as much data and documentation as possible (closed #236, thanks @JaelTan) -- Some further rationalisation of the documentation -- Dropped visualization vignette for now +- Updated the DESCRIPTION and CITATION +- Renamed `edge_*()` to `tie_*()` to offer more (SNA) consistent vocabulary +- Added DOIs to as much data and documentation as possible (closed #236, thanks @JaelTan) +- Some further rationalisation of the documentation +- Dropped visualization vignette for now ## Manipulation -- Added methods for converting `network.goldfish` objects (and linked events and nodelists) to migraph-compatible objects (closed #96) -- Renamed `add_node_attributes()` to `add_node_attribute()` and `add_edge_attributes()` to `add_tie_attribute()` +- Added methods for converting `network.goldfish` objects (and linked events and nodelists) to migraph-compatible objects (closed #96) +- Renamed `add_node_attributes()` to `add_node_attribute()` and `add_edge_attributes()` to `add_tie_attribute()` ## Marks -- All `is_*()` are now considered graph-level 'marks' -- Added 'node_mark' and 'tie_mark' classes with printing methods (closed #233) -- Added `node_is_isolate()` for marking isolates -- Added `node_is_max()`, `node_is_min()`, `tie_is_max()`, `tie_is_min()` for converting 'measures' into 'marks' +- All `is_*()` are now considered graph-level 'marks' +- Added 'node_mark' and 'tie_mark' classes with printing methods (closed #233) +- Added `node_is_isolate()` for marking isolates +- Added `node_is_max()`, `node_is_min()`, `tie_is_max()`, `tie_is_min()` for converting 'measures' into 'marks' ## Measures -- Printing 'node_measure' class objects now is prettier, extending the width of the console, - indicating how many additional observations, and separates out each mode (closed #232) +- Printing 'node_measure' class objects now is prettier, extending the width of the console, indicating how many additional observations, and separates out each mode (closed #232) ## Motifs -- Added print method for `graph_motif` (fixed #234) +- Added print method for `graph_motif` (fixed #234) ## Memberships -- Equivalence examples now `\dontrun` +- Equivalence examples now `\dontrun` ## Models -- `cluster_concor()` and `cluster_hierarchical()` are now exported +- `cluster_concor()` and `cluster_hierarchical()` are now exported ## Mapping -- `autographr()` no longer requires "highlight_measure" and "identify_function" arguments - as users can now convert 'measures' to 'marks' and use these for "node_color" or "edge_color" +- `autographr()` no longer requires "highlight_measure" and "identify_function" arguments as users can now convert 'measures' to 'marks' and use these for "node_color" or "edge_color" ## Data -- Added prints of each data object to `@format` for more consistent documentation -- Added `ison_brandes2` dataset, a two-mode version of the original one-mode dataset -- Added `mpn_cow_trade` and `mpn_cow_igo` datasets (thanks @JaelTan) -- Fixed non-unique names in `mpn_elite_mex` +- Added prints of each data object to `@format` for more consistent documentation +- Added `ison_brandes2` dataset, a two-mode version of the original one-mode dataset +- Added `mpn_cow_trade` and `mpn_cow_igo` datasets (thanks @JaelTan) +- Fixed non-unique names in `mpn_elite_mex` # migraph 0.10.2 ## Memberships -- Further shortened equivalence examples +- Further shortened equivalence examples # migraph 0.10.1 ## Measures -- Added `node_reach()` for calculating reach centrality (closed #196) -- Separated (again) centrality and centralisation documentation +- Added `node_reach()` for calculating reach centrality (closed #196) +- Separated (again) centrality and centralisation documentation ## Memberships -- Shortened equivalence examples +- Shortened equivalence examples # migraph 0.10.0 ## Package -- Reduced package dependencies by 5 - - `{concaveman}`, `{ggdendro}`, `{oaqc}` are now Suggests; the user is prompted to install them when required in `autographr()`, `plot.member()`, and `node_quad_census()` respectively - - `{stringr}` and `{tibble}` replaced with base or other code and therefore no longer necessary -- Relabelled scripts to follow website function structure - - Added `@family` tags for improved cross-referencing - - Added a lot more references/sources -- README elaborated, including listing functions and data in the package -- Switched to S3 classes as outputs for most functions - - Several methods, e.g. `print()`, `plot()`, `summary()`, have been added for them (see appropriate sections below) +- Reduced package dependencies by 5 + - `{concaveman}`, `{ggdendro}`, `{oaqc}` are now Suggests; the user is prompted to install them when required in `autographr()`, `plot.member()`, and `node_quad_census()` respectively + - `{stringr}` and `{tibble}` replaced with base or other code and therefore no longer necessary +- Relabelled scripts to follow website function structure + - Added `@family` tags for improved cross-referencing + - Added a lot more references/sources +- README elaborated, including listing functions and data in the package +- Switched to S3 classes as outputs for most functions + - Several methods, e.g. `print()`, `plot()`, `summary()`, have been added for them (see appropriate sections below) ## Making -- All `create_` and `generate_` functions now: - - work when `n` passed an existing network - - work with two-mode networks, including `create_tree()`, `generate_smallworld()`, `generate_scalefree()` - - return undirected network by default -- Some `create_` functions can now take a membership vector or split into equal partitions by default - - `create_components()` no longer accepts a number of components, instead relying on the membership vector - - Added `create_core()` for creating core-periphery graphs -- `generate_random()` now inherits attributes from any network +- All `create_` and `generate_` functions now: + - work when `n` passed an existing network + - work with two-mode networks, including `create_tree()`, `generate_smallworld()`, `generate_scalefree()` + - return undirected network by default +- Some `create_` functions can now take a membership vector or split into equal partitions by default + - `create_components()` no longer accepts a number of components, instead relying on the membership vector + - Added `create_core()` for creating core-periphery graphs +- `generate_random()` now inherits attributes from any network ## Manipulation -- Added a couple of `to_` functions useful for working with networks of different types - - Added `to_redirected()` for adding or swapping direction to networks (closed #219) - - Added `to_blocks()` for reducing a network down by a membership vector; `blockmodel()` and `reduce_graph()` are now deprecated - - `to_multilevel.igraph()` now only works on two-mode networks; returns the original network if passed a one-mode network -- Fixed some bugs in a number of `is_` functions - - `is_signed.data.frame()` and `is_signed.matrix()` now rely on new helper `is.wholenumber()` rather than misleading `is.integer()` - - `is_directed.igraph()` and `is_directed.matrix()` now return FALSE for two-mode networks - - `is_connected()` now returns result for strong components if directed and weak components if undirected -- `as_igraph.data.frame()` now infers third column as weight +- Added a couple of `to_` functions useful for working with networks of different types + - Added `to_redirected()` for adding or swapping direction to networks (closed #219) + - Added `to_blocks()` for reducing a network down by a membership vector; `blockmodel()` and `reduce_graph()` are now deprecated + - `to_multilevel.igraph()` now only works on two-mode networks; returns the original network if passed a one-mode network +- Fixed some bugs in a number of `is_` functions + - `is_signed.data.frame()` and `is_signed.matrix()` now rely on new helper `is.wholenumber()` rather than misleading `is.integer()` + - `is_directed.igraph()` and `is_directed.matrix()` now return FALSE for two-mode networks + - `is_connected()` now returns result for strong components if directed and weak components if undirected +- `as_igraph.data.frame()` now infers third column as weight ## Marks -- Added new set of functions that return logical vectors for nodes and edges: - - `edge_multiple()`, `edge_loop()`, `edge_reciprocal()` moved from measures - - Added `edge_bridges()` +- Added new set of functions that return logical vectors for nodes and edges: + - `edge_multiple()`, `edge_loop()`, `edge_reciprocal()` moved from measures + - Added `edge_bridges()` ## Measures -- A new `"edge_measure"` S3 class has been added, along with `print()` and `plot()` methods -- Added `summary.node_measure()` method for printing a summary by a membership vector; `summarise_statistics()` is now deprecated -- All cohesion, connection, and diversity measures now return `"graph_measure"` class results - - `graph_components()` now calculates strong components for directed networks else weak components - - `print.graph_measure()` now correctly labels two-mode results where a vector is given -- Added new script for measuring features, including `graph_smallworld()` - - Added `graph_core()` for calculating correlation of an observed network to a core-periphery network of the same dimensions (closed #39) - - Added `graph_factions()` for calculating correlation of an observed network to a component network of the same dimensions (closed #40) - - Added `graph_modularity()` for calculating modularity of an observed network, including modularity for two-mode networks (closed #144) -- Added new script for measuring structural holes, including `node_constraint()` - - Added several additional measures of structural holes: `node_bridges()`, `node_redundancy()`, `node_effsize()`, `node_efficiency()`, `node_hierarchy()` -- `node_betweenness()` no longer needs `nobigint` argument; just uses default from `{igraph}` +- A new `"edge_measure"` S3 class has been added, along with `print()` and `plot()` methods +- Added `summary.node_measure()` method for printing a summary by a membership vector; `summarise_statistics()` is now deprecated +- All cohesion, connection, and diversity measures now return `"graph_measure"` class results + - `graph_components()` now calculates strong components for directed networks else weak components + - `print.graph_measure()` now correctly labels two-mode results where a vector is given +- Added new script for measuring features, including `graph_smallworld()` + - Added `graph_core()` for calculating correlation of an observed network to a core-periphery network of the same dimensions (closed #39) + - Added `graph_factions()` for calculating correlation of an observed network to a component network of the same dimensions (closed #40) + - Added `graph_modularity()` for calculating modularity of an observed network, including modularity for two-mode networks (closed #144) +- Added new script for measuring structural holes, including `node_constraint()` + - Added several additional measures of structural holes: `node_bridges()`, `node_redundancy()`, `node_effsize()`, `node_efficiency()`, `node_hierarchy()` +- `node_betweenness()` no longer needs `nobigint` argument; just uses default from `{igraph}` ## Motifs -- Added `"node_motif"` S3 class for the output of `node_*_census()` functions - - Added `print.node_motif()` for tibble-printing of census results - - Added `summary.node_motif()` to summarise censuses by a membership vector, replacing `group_tie_census()` and `group_triad_census()`, which are now deprecated -- Added `"graph_motif"` S3 class for the output of `graph_*_census()` functions -- Added `node_path_census()` for returning the shortest distances from each node to every other node (closed #222) -- `node_tie_census()` now creates unique column names +- Added `"node_motif"` S3 class for the output of `node_*_census()` functions + - Added `print.node_motif()` for tibble-printing of census results + - Added `summary.node_motif()` to summarise censuses by a membership vector, replacing `group_tie_census()` and `group_triad_census()`, which are now deprecated +- Added `"graph_motif"` S3 class for the output of `graph_*_census()` functions +- Added `node_path_census()` for returning the shortest distances from each node to every other node (closed #222) +- `node_tie_census()` now creates unique column names ## Memberships -- Added new `"node_member"` S3 class for vectors of nodes' cluster memberships - - The class hides a hierarchical clustering object as an attribute, so `plot.node_member()` replaces `ggtree()` -- Moved to an equivalence identification scheme that hides many of the technical aspects from users when unnecessary - - Added `node_equivalence()` for identifying nodes' membership in classes equivalent with respect to some arbitrary motif census - - `"hierarchical"` and `"concor"` now options for `cluster` within `node_equivalence()`; `blockmodel_concor()` is now deprecated (closed #123) - - `"elbow"` now an option for `k` selection within `node_equivalence()`; `ggidentify_clusters()` is now deprecated - - Added `"silhouette"` and `"strict"` options for `k` selection (closed #197) - - Added option for `k` to be defined - - There is now an argument `distance` passed to `stats::dist` that defines the distance metric (closed #36) - - The argument `range` constrains the number of `k` evaluated by `"elbow"` and `"silhouette"` to improve parsimony and avoid long elapsed times - - Added `node_automorphic_equivalence()` for identifying nodes' membership in automorphically-equivalent classes (closed #187) - - `node_structural_equivalence()` replaces `cluster_structural_equivalence()` - - `node_regular_equivalence()` replaces `cluster_regular_equivalence()` -- Added community identification scheme that mirrors equivalence identification in many respects - - Added `node_kernaghinlin()` for identifying nodes' membership in communities based on the Kernaghin-Lin algorithm (thank you, @jaeltan, closed #198) -- Added connected identification scheme that mirrors equivalence identification in many respects - - Added `node_coreness()` for nodes' _k_-core score (closed #200) - - Added `node_strong_components()` and `node_weak_components()` for more direct calls; `node_components()` now calculates strong components for directed networks else weak components +- Added new `"node_member"` S3 class for vectors of nodes' cluster memberships + - The class hides a hierarchical clustering object as an attribute, so `plot.node_member()` replaces `ggtree()` +- Moved to an equivalence identification scheme that hides many of the technical aspects from users when unnecessary + - Added `node_equivalence()` for identifying nodes' membership in classes equivalent with respect to some arbitrary motif census + - `"hierarchical"` and `"concor"` now options for `cluster` within `node_equivalence()`; `blockmodel_concor()` is now deprecated (closed #123) + - `"elbow"` now an option for `k` selection within `node_equivalence()`; `ggidentify_clusters()` is now deprecated + - Added `"silhouette"` and `"strict"` options for `k` selection (closed #197) + - Added option for `k` to be defined + - There is now an argument `distance` passed to `stats::dist` that defines the distance metric (closed #36) + - The argument `range` constrains the number of `k` evaluated by `"elbow"` and `"silhouette"` to improve parsimony and avoid long elapsed times + - Added `node_automorphic_equivalence()` for identifying nodes' membership in automorphically-equivalent classes (closed #187) + - `node_structural_equivalence()` replaces `cluster_structural_equivalence()` + - `node_regular_equivalence()` replaces `cluster_regular_equivalence()` +- Added community identification scheme that mirrors equivalence identification in many respects + - Added `node_kernaghinlin()` for identifying nodes' membership in communities based on the Kernaghin-Lin algorithm (thank you, @jaeltan, closed #198) +- Added connected identification scheme that mirrors equivalence identification in many respects + - Added `node_coreness()` for nodes' *k*-core score (closed #200) + - Added `node_strong_components()` and `node_weak_components()` for more direct calls; `node_components()` now calculates strong components for directed networks else weak components ## Models -- A single `"graph_test"` S3 class replaces `"cug_test"` and `"qap_test"` - - `plot.graph_test()` replaces `plot.cug_test()` and `plot.qap_test()` - - Added `print.graph_test()` method -- `plot.matrix()` now plots adjacency/incidence matrices with sorting and horizontal/vertical lines if a membership vector is provided, -effectively replacing `plot.block_model()` +- A single `"graph_test"` S3 class replaces `"cug_test"` and `"qap_test"` + - `plot.graph_test()` replaces `plot.cug_test()` and `plot.qap_test()` + - Added `print.graph_test()` method +- `plot.matrix()` now plots adjacency/incidence matrices with sorting and horizontal/vertical lines if a membership vector is provided, effectively replacing `plot.block_model()` ## Mapping -- `autographr()` can highlight nodes that max (by default) some measure (thank you, @BBieri, closed #224) -- Added `layout_tbl_graph_stressgrid()` as an extra option -- `ggatyear()` is deprecated +- `autographr()` can highlight nodes that max (by default) some measure (thank you, @BBieri, closed #224) +- Added `layout_tbl_graph_stressgrid()` as an extra option +- `ggatyear()` is deprecated ## Data -- `ison_algebra`'s edge attributes now named "friends", "social", and "tasks" +- `ison_algebra`'s edge attributes now named "friends", "social", and "tasks" # migraph 0.9.3 ## Package -- Trialling `{roxytest}` -- Updated favicons -- Updated several vignettes - - Closed #154 by building out data vignette - - Updated centrality vignette with more modern plotting -- Added some more informative documentation families +- Trialling `{roxytest}` +- Updated favicons +- Updated several vignettes + - Closed #154 by building out data vignette + - Updated centrality vignette with more modern plotting +- Added some more informative documentation families ## Making -- Folded `m` argument into `p` for `generate_random()`, `p` can now be passed an integer to indicate the number of ties the network should have +- Folded `m` argument into `p` for `generate_random()`, `p` can now be passed an integer to indicate the number of ties the network should have ## Manipulation -- Refactored `to_edges()` to be ~26 times faster on average -- Corrected edge labelling in `to_edges()` -- Using `to_subgraph()` now instead of `dplyr::filter()` or `strain()` +- Refactored `to_edges()` to be \~26 times faster on average +- Corrected edge labelling in `to_edges()` +- Using `to_subgraph()` now instead of `dplyr::filter()` or `strain()` ## Mapping -- Layouts now use `times` argument instead of `maxiter` +- Layouts now use `times` argument instead of `maxiter` ## Measures -- Renamed `"measure"` class `"node_measure"` and added `"graph_measure"` class with print method -- Overhaul of centrality measures - - Centrality and centralization measures now return normalized scores by default, `normalized` is now the second argument - - `directed` and `weights` arguments have been removed and are now imputed, if this is undesired please use `to_*()` first - - `node_degree()` now calculates strength centrality if network is weighted - - `node_eigenvector()` and `graph_eigenvector()` both work with two-mode networks - - Added `edge_degree()` and `edge_eigenvector()`, which both just apply the corresponding nodal measure to the edge graph -- `edge_mutual()` renamed to `edge_reciprocal()` -- Closed #225 by adding `graph_assortativity()` +- Renamed `"measure"` class `"node_measure"` and added `"graph_measure"` class with print method +- Overhaul of centrality measures + - Centrality and centralization measures now return normalized scores by default, `normalized` is now the second argument + - `directed` and `weights` arguments have been removed and are now imputed, if this is undesired please use `to_*()` first + - `node_degree()` now calculates strength centrality if network is weighted + - `node_eigenvector()` and `graph_eigenvector()` both work with two-mode networks + - Added `edge_degree()` and `edge_eigenvector()`, which both just apply the corresponding nodal measure to the edge graph +- `edge_mutual()` renamed to `edge_reciprocal()` +- Closed #225 by adding `graph_assortativity()` ## Modelling -- Closed #151 with blockmodel coloring for signed graphs +- Closed #151 with blockmodel coloring for signed graphs ## Data -- Dropped weight from `mpn_elite_mex` -- Dropped direction from `ison_brandes` +- Dropped weight from `mpn_elite_mex` +- Dropped direction from `ison_brandes` # migraph 0.9.2 ## Package -- Streamlined some examples to reduce testing time -- Fixed a DOI URL for Ortmann and Brandes reference +- Streamlined some examples to reduce testing time +- Fixed a DOI URL for Ortmann and Brandes reference # migraph 0.9.1 ## Package -- Streamlined some tests to reduce testing time +- Streamlined some tests to reduce testing time ## Manipulation -- `is_multiplex.igraph()` and `is_multiplex.tbl_graph()` now checks for multiple edge attributes -- Added `strain()` as wrapper for `{dplyr}`'s `filter()`, renamed to avoid conflicts with `{stats}` +- `is_multiplex.igraph()` and `is_multiplex.tbl_graph()` now checks for multiple edge attributes +- Added `strain()` as wrapper for `{dplyr}`'s `filter()`, renamed to avoid conflicts with `{stats}` ## Data -- `ison_algebra` now unlabelled +- `ison_algebra` now unlabelled # migraph 0.9.0 ## Package -- Recognised contributors Henrique Sposito and Jael Tan -- Updated dependencies - - `{readxl}` is now _suggested_, but required if importing from an Excel sheet - - `{patchwork}` replaces `{gridExtra}` to make for more concise multiplot visualisations - - `{dplyr}` also serves to export `{magrittr}`'s pipe - - `{RColorBrewer}` has been dropped and the `Dark2` discrete set of colors is now internal -- README has been updated and now compiles from a .Rmd file -- Changed website theme to 'superhero' -- All prior deprecated functions have been removed -- Increased testing to ~80% (closed #126, #212) -- CITATION has been updated too +- Recognised contributors Henrique Sposito and Jael Tan +- Updated dependencies + - `{readxl}` is now *suggested*, but required if importing from an Excel sheet + - `{patchwork}` replaces `{gridExtra}` to make for more concise multiplot visualisations + - `{dplyr}` also serves to export `{magrittr}`'s pipe + - `{RColorBrewer}` has been dropped and the `Dark2` discrete set of colors is now internal +- README has been updated and now compiles from a .Rmd file +- Changed website theme to 'superhero' +- All prior deprecated functions have been removed +- Increased testing to \~80% (closed #126, #212) +- CITATION has been updated too ## Making -- Moved to @describeIn documentation (closed #215) -- Distinguished `directed` and `direction` arguments in some functions; whereas `directed` is always logical (TRUE/FALSE), `direction` expects a character string, e.g. "in", "out", or "undirected" -- `generate_permutation()` now has an additional logical argument, `with_attr`, that indicates whether any attributes from the original data should be passed to the permuted object -- All `create_*()` functions now accept existing objects as their first argument and will create networks with the same dimensions -- `read_pajek()` now imports nodal attributes alongside the main edges -- `read_ucinet()` now enjoys clearer documentation +- Moved to @describeIn documentation (closed #215) +- Distinguished `directed` and `direction` arguments in some functions; whereas `directed` is always logical (TRUE/FALSE), `direction` expects a character string, e.g. "in", "out", or "undirected" +- `generate_permutation()` now has an additional logical argument, `with_attr`, that indicates whether any attributes from the original data should be passed to the permuted object +- All `create_*()` functions now accept existing objects as their first argument and will create networks with the same dimensions +- `read_pajek()` now imports nodal attributes alongside the main edges +- `read_ucinet()` now enjoys clearer documentation ## Manipulation -- All `as_*()` functions now retain weights where present; if you want an unweighted result, use `is_unweighted()` afterwards - - `as_edgelist.network()` now better handles edge weights - - `as_matrix.igraph()` now better handles edge signs -- Pivoted to S3 methods for most manipulation functions for better dispatching and performance - - Added matrix, data.frame, network, igraph, and tbl_graph methods for `is_twomode()`, `is_directed()`, `is_weighted()`, `is_labelled()`, `is_signed()`, `is_multiplex()`, `is_complex()`, and `is_graph()` - - Added data.frame methods for `as_edgelist()`, and `to_unweighted()`, and improved the data.frame method for `as_matrix()` - - Added data.frame and matrix methods for `to_named()` and `to_unsigned()` -- Added `to_edges()` for creating adjacency matrices using a network's edges as nodes -- Renamed `project_rows()` and `project_cols()` functions to `to_mode1()` and `to_mode2()`, which is both more consistent with other functions naming conventions and more generic by avoiding the matrix-based row/column distinction -- Added `node_mode()`, which returns a vector of the mode assignments of the nodes in a network -- Added `edge_signs()`, which returns a vector of the sign assignments of the edges in a network +- All `as_*()` functions now retain weights where present; if you want an unweighted result, use `is_unweighted()` afterwards + - `as_edgelist.network()` now better handles edge weights + - `as_matrix.igraph()` now better handles edge signs +- Pivoted to S3 methods for most manipulation functions for better dispatching and performance + - Added matrix, data.frame, network, igraph, and tbl_graph methods for `is_twomode()`, `is_directed()`, `is_weighted()`, `is_labelled()`, `is_signed()`, `is_multiplex()`, `is_complex()`, and `is_graph()` + - Added data.frame methods for `as_edgelist()`, and `to_unweighted()`, and improved the data.frame method for `as_matrix()` + - Added data.frame and matrix methods for `to_named()` and `to_unsigned()` +- Added `to_edges()` for creating adjacency matrices using a network's edges as nodes +- Renamed `project_rows()` and `project_cols()` functions to `to_mode1()` and `to_mode2()`, which is both more consistent with other functions naming conventions and more generic by avoiding the matrix-based row/column distinction +- Added `node_mode()`, which returns a vector of the mode assignments of the nodes in a network +- Added `edge_signs()`, which returns a vector of the sign assignments of the edges in a network ## Mapping -- Added 'visualization' vignette that starts to introduce how `autographr()` works and how `{ggraph}` extends this -- `autographr()` now incorporates `ggidentify()` functionality (closed #150) -- `{patchwork}` is now used to assemble multiple plots together -- Fixed #204 layout issues with `ggatyear()` +- Added 'visualization' vignette that starts to introduce how `autographr()` works and how `{ggraph}` extends this +- `autographr()` now incorporates `ggidentify()` functionality (closed #150) +- `{patchwork}` is now used to assemble multiple plots together +- Fixed #204 layout issues with `ggatyear()` ## Measures -- Added new `measure` class and directed most `node_*()` functions to create objects of this class - - A print method for this class prints an abbreviated vector (the full vector is always still contained within the object) and prints elements from both modes in the event that the original object was two-mode (closed #202) - - A plot method replaces `ggdistrib()` and offers "hist" and "dens" methods for histograms and density plots respectively -- Added some edge-based centrality measures (closed #165) - - `edge_betweenness()` wraps `{igraph}`'s function of the same name - - `edge_closeness()` measures the closeness centrality of nodes in an edge adjacency -- Added several more measures of connectedness - - `node_cuts()` identifies articulation points (nodes) in a network - - `edge_bridges()` identifies edges that serve as bridges in a network - - `graph_cohesion()` measures how many nodes would need to be removed to increase the number of components (closed #192) - - `graph_adhesion()` measures how many edges would need to be removed to increase the number of components - - `graph_length()` measures the average path length - - `graph_diameter()` measures the longest path length -- Removed `node_smallworld()` and added `graph_smallworld()`, which works with both one- and two-mode networks (fixed #214) +- Added new `measure` class and directed most `node_*()` functions to create objects of this class + - A print method for this class prints an abbreviated vector (the full vector is always still contained within the object) and prints elements from both modes in the event that the original object was two-mode (closed #202) + - A plot method replaces `ggdistrib()` and offers "hist" and "dens" methods for histograms and density plots respectively +- Added some edge-based centrality measures (closed #165) + - `edge_betweenness()` wraps `{igraph}`'s function of the same name + - `edge_closeness()` measures the closeness centrality of nodes in an edge adjacency +- Added several more measures of connectedness + - `node_cuts()` identifies articulation points (nodes) in a network + - `edge_bridges()` identifies edges that serve as bridges in a network + - `graph_cohesion()` measures how many nodes would need to be removed to increase the number of components (closed #192) + - `graph_adhesion()` measures how many edges would need to be removed to increase the number of components + - `graph_length()` measures the average path length + - `graph_diameter()` measures the longest path length +- Removed `node_smallworld()` and added `graph_smallworld()`, which works with both one- and two-mode networks (fixed #214) ## Motifs -- Added some guidance to the naming convention used in `node_quad_census()` +- Added some guidance to the naming convention used in `node_quad_census()` ## Models -- Extended `network_reg()`'s formula-based system - - `network_reg()` can now handle binary and multiple categorical variables (factors and characters, closed #211); - - `network_reg()` can now manage interactions specified in the common syntax; `var1 * var2` expands to `var1 + var2 + var1:var2` (closed #163) - - `dist()` and `sim()` effects have been added (closed #207) -- `network_reg()` now employs logistic regression to estimate a binary outcome and linear regression to estimate a continuous outcome (closed #184) -- `network_reg()` now uses Dekker et al's semi-partialling procedure by default for multivariate specifications (closed #206), defaulting to _y_-permutations in the case of a single predictor (closed #208) -- Added parallelisation to Monte Carlo based tests - - Refactored `network_reg()`, relying on `{furrr}` for potential parallelisation and `{progressr}` for progress reports (closed #185, #186) - - Refactored `test_random()` and `test_permutation()`, relying on `{furrr}` for potential parallelisation and `{progressr}` for progress reports; note that `nSim` argument now `times` (closed #199) -- Added `{broom}` S3 methods for `netlm` and `netlogit` class objects (closed #183) - - `tidy()` extracts coefficients and related values - - `glance()`extracts model-level values such as `R^2` -- Added plot method for `netlm` and `netlogit` class objects (closed #216), which plots the empirical distribution for each test statistic, indicates percentiles relating to common critical values, and superimposes the observed coefficients -- Added plot method for `cug_test` and `qap_test` class objects, which plots the empirical distribution, highlighting tails beyond some critical value (closed #213), and superimposing the observed coefficient and, possibly, 0 -- Relabelled some classes to avoid loading conflicts with `{sna}` - - `print.block_model()` replaces `print.blockmodel()` - - `plot.block_model()` replaces `plot.blockmodel()` -- Reduced the number of simulations used in tests, examples, and vignettes to avoid CRAN warnings +- Extended `network_reg()`'s formula-based system + - `network_reg()` can now handle binary and multiple categorical variables (factors and characters, closed #211); + - `network_reg()` can now manage interactions specified in the common syntax; `var1 * var2` expands to `var1 + var2 + var1:var2` (closed #163) + - `dist()` and `sim()` effects have been added (closed #207) +- `network_reg()` now employs logistic regression to estimate a binary outcome and linear regression to estimate a continuous outcome (closed #184) +- `network_reg()` now uses Dekker et al's semi-partialling procedure by default for multivariate specifications (closed #206), defaulting to *y*-permutations in the case of a single predictor (closed #208) +- Added parallelisation to Monte Carlo based tests + - Refactored `network_reg()`, relying on `{furrr}` for potential parallelisation and `{progressr}` for progress reports (closed #185, #186) + - Refactored `test_random()` and `test_permutation()`, relying on `{furrr}` for potential parallelisation and `{progressr}` for progress reports; note that `nSim` argument now `times` (closed #199) +- Added `{broom}` S3 methods for `netlm` and `netlogit` class objects (closed #183) + - `tidy()` extracts coefficients and related values + - `glance()`extracts model-level values such as `R^2` +- Added plot method for `netlm` and `netlogit` class objects (closed #216), which plots the empirical distribution for each test statistic, indicates percentiles relating to common critical values, and superimposes the observed coefficients +- Added plot method for `cug_test` and `qap_test` class objects, which plots the empirical distribution, highlighting tails beyond some critical value (closed #213), and superimposing the observed coefficient and, possibly, 0 +- Relabelled some classes to avoid loading conflicts with `{sna}` + - `print.block_model()` replaces `print.blockmodel()` + - `plot.block_model()` replaces `plot.blockmodel()` +- Reduced the number of simulations used in tests, examples, and vignettes to avoid CRAN warnings ## Data -- Updated several names of datasets for consistency and conciseness - - `ison_southern_women` instead of `southern_women` - - `ison_brandes` instead of `brandes` - - `ison_networkers` instead of `ison_eies` - - `ison_algebra` instead of `ison_m182` - - `ison_adolescents` instead of `ison_coleman` -- Extended several datasets - - `mpn_elite_mex` is extended with data from Pajek and with help from Frank Heber - - `ison_networkers` becomes named with information from `{tnet}` -- Elaborated documentation of most `mpn_*` and `ison_*` datasets, including references/sources +- Updated several names of datasets for consistency and conciseness + - `ison_southern_women` instead of `southern_women` + - `ison_brandes` instead of `brandes` + - `ison_networkers` instead of `ison_eies` + - `ison_algebra` instead of `ison_m182` + - `ison_adolescents` instead of `ison_coleman` +- Extended several datasets + - `mpn_elite_mex` is extended with data from Pajek and with help from Frank Heber + - `ison_networkers` becomes named with information from `{tnet}` +- Elaborated documentation of most `mpn_*` and `ison_*` datasets, including references/sources # migraph 0.8.13 ## Modelling -* Closed #149 by adding extra column to node_tie_census in `cluster_structural_equivalence()` for isolates - - Note that this renders all isolates structurally equivalent +- Closed #149 by adding extra column to node_tie_census in `cluster_structural_equivalence()` for isolates + - Note that this renders all isolates structurally equivalent # migraph 0.8.12 ## Package -* Closed #168 by adding `{patchwork}` to suggested packages in DESCRIPTION -* Updated function reference page on website + +- Closed #168 by adding `{patchwork}` to suggested packages in DESCRIPTION +- Updated function reference page on website ## Manipulation -* Updated `add_` functions - * Closed #178 by adding name to existing edges when further edges added in - `mutate_edges()` - * Closed #179 by inferring an attribute vector is for one of the two modes - where possible in `add_node_attributes()` -* Added `is_` methods: `is_multiplex()`, `is_uniplex()`, `is_acyclic()` -* Added `edge_` functions to identify edges by properties: `edge_mutual()`, -`edge_multiple()`, `edge_loop()` + +- Updated `add_` functions + - Closed #178 by adding name to existing edges when further edges added in `mutate_edges()` + - Closed #179 by inferring an attribute vector is for one of the two modes where possible in `add_node_attributes()` +- Added `is_` methods: `is_multiplex()`, `is_uniplex()`, `is_acyclic()` +- Added `edge_` functions to identify edges by properties: `edge_mutual()`, `edge_multiple()`, `edge_loop()` # migraph 0.8.11 ## Import and export -- Fixed #172 by removing redundant header argument in `read_nodelist()` and - `read_edgelist()` + +- Fixed #172 by removing redundant header argument in `read_nodelist()` and `read_edgelist()` ## Package -- Fixed #173 by extending `as_network()` method to convert correctly form - an `{igraph}` to a `{network}` object. -- Removed `ggraphgrid()` documentation + +- Fixed #173 by extending `as_network()` method to convert correctly form an `{igraph}` to a `{network}` object. +- Removed `ggraphgrid()` documentation # migraph 0.8.10 ## Import and export -* Replaced xlsx dependency in `read_edgelist()` and `read_nodelist()` to readxl -to avoid Java dependency -* Replaced xlsx dependency in `write_edgelist()` and `write_nodelist()` to avoid -Java dependency - * Note that these functions will now export to .csv rather than .xlsx - + +- Replaced xlsx dependency in `read_edgelist()` and `read_nodelist()` to readxl to avoid Java dependency +- Replaced xlsx dependency in `write_edgelist()` and `write_nodelist()` to avoid Java dependency + - Note that these functions will now export to .csv rather than .xlsx + ## Manipulation -* Fixed direction recognition bug in `as_network()`, `as_igraph()`, and -`is_directed()` + +- Fixed direction recognition bug in `as_network()`, `as_igraph()`, and `is_directed()` # migraph 0.8.9 ## Package -* Closed #139 by adding vignette on importing and connecting data + +- Closed #139 by adding vignette on importing and connecting data ## Import and export -* Added `read_` and `write_` functions and updated documentation - * Closed #137 by adding `read_edgelist()` for importing edgelists from - Excel and csv files - * Closed #170 by adding `read_pajek()` for importing .net and .paj files - * Added `write_edgelist()`, `write_nodelist`, `write_pajek()`, and - `write_ucinet()` for exporting into various file formats (Excel, csv, - Pajek, and UCINET) - * Closed #140 by adding links to further data resources + +- Added `read_` and `write_` functions and updated documentation + - Closed #137 by adding `read_edgelist()` for importing edgelists from Excel and csv files + - Closed #170 by adding `read_pajek()` for importing .net and .paj files + - Added `write_edgelist()`, `write_nodelist`, `write_pajek()`, and `write_ucinet()` for exporting into various file formats (Excel, csv, Pajek, and UCINET) + - Closed #140 by adding links to further data resources ## Manipulation -* Added `is_graph()` to check if an object is a graph or not -* Extended `as_network()` to retain attributes -* Fixed bugs in `as_` and `to_` functions - * Fixed bug in `as_` functions to convert from dataframes instead of - tibbles - * Fixed bug in conversion from network to igraph object in `as_igraph()` - function - * Fixed bug in `to_undirected()` function to work with network objects - * Fixed bug in `to_main_component()` function so that it retains vertex - attributes in network objects -* Added `edge_attribute()` to grab a named edge attribute from a graph/network -* Updated `to_unweighted()` to prevent conversion of network object into igraph -object when deleting weights + +- Added `is_graph()` to check if an object is a graph or not +- Extended `as_network()` to retain attributes +- Fixed bugs in `as_` and `to_` functions + - Fixed bug in `as_` functions to convert from dataframes instead of tibbles + - Fixed bug in conversion from network to igraph object in `as_igraph()` function + - Fixed bug in `to_undirected()` function to work with network objects + - Fixed bug in `to_main_component()` function so that it retains vertex attributes in network objects +- Added `edge_attribute()` to grab a named edge attribute from a graph/network +- Updated `to_unweighted()` to prevent conversion of network object into igraph object when deleting weights ## Measures -* Closed #143 by adding nodal summary by cluster function `summarise_statistics()` + +- Closed #143 by adding nodal summary by cluster function `summarise_statistics()` ## Modelling -* Fixed `network_reg()` example + +- Fixed `network_reg()` example ## Visualisation -* Closed #117 by updating the node/edge/arrow size limits in `autographr()` + +- Closed #117 by updating the node/edge/arrow size limits in `autographr()` # migraph 0.8.8 ## Package -- Added start to network linear model part of practical 7 vignette -- Thanks to @BBieri for adding many tests and working on igraph<->network interchange +- Added start to network linear model part of practical 7 vignette +- Thanks to @BBieri for adding many tests and working on igraph\<-\>network interchange ## Data -- Added `ison_eies` dataset for use in practical 7 vignette +- Added `ison_eies` dataset for use in practical 7 vignette ## Manipulation -- The `as_matrix()` method for networks now works with two-mode and weighted networks -- The `as_igraph()` method for matrices now checks for weights independently of coercion -- The `as_igraph()` method for networks now works with two-mode and weighted networks -- The `as_network()` method for matrices now works with two-mode and weighted networks -- The `as_network()` method for edgelists, igraph, and tidygraphs now works with weighted networks -- Added `to_unnamed()` method for edge lists -- Added `to_simplex()` method for matrices -- Added `to_main_component()` method for networks -- Added `to_multilevel()` method for matrices -- `mutate_edges()` now coalesces rows of edges +- The `as_matrix()` method for networks now works with two-mode and weighted networks +- The `as_igraph()` method for matrices now checks for weights independently of coercion +- The `as_igraph()` method for networks now works with two-mode and weighted networks +- The `as_network()` method for matrices now works with two-mode and weighted networks +- The `as_network()` method for edgelists, igraph, and tidygraphs now works with weighted networks +- Added `to_unnamed()` method for edge lists +- Added `to_simplex()` method for matrices +- Added `to_main_component()` method for networks +- Added `to_multilevel()` method for matrices +- `mutate_edges()` now coalesces rows of edges ## Measures -- Fixed bug where clusters were not being reported in the correct order in `graph_blau_index()` +- Fixed bug where clusters were not being reported in the correct order in `graph_blau_index()` ## Modelling -- Fixed one-mode bug with `generate_permutation()` and thus `test_permutation()` -- Renamed `netlm()` to `network_reg()` to avoid frustrating conflicts - - `network_reg()` now accepts migraph-consistent objects - - `network_reg()` now accepts formula terms such as `ego()`, `alter()`, and `same()` +- Fixed one-mode bug with `generate_permutation()` and thus `test_permutation()` +- Renamed `netlm()` to `network_reg()` to avoid frustrating conflicts + - `network_reg()` now accepts migraph-consistent objects + - `network_reg()` now accepts formula terms such as `ego()`, `alter()`, and `same()` # migraph 0.8.7 ## Package -- Added new issue templates and refined the wording in existing templates -- Improved documentation across many help pages -- Closed #146 by adding vignette on homophily +- Added new issue templates and refined the wording in existing templates +- Improved documentation across many help pages +- Closed #146 by adding vignette on homophily ## Data -- Added `generate_permutation()` which takes an object and returns an object - with the edges permuted, but retaining all nodal attributes -- Made `generate_random()` also work with an existing object as input, - in which it will return a random graph with the same dimensions and density -- Consolidated data scripts +- Added `generate_permutation()` which takes an object and returns an object with the edges permuted, but retaining all nodal attributes +- Made `generate_random()` also work with an existing object as input, in which it will return a random graph with the same dimensions and density +- Consolidated data scripts ## Manipulation -- Added `mutate_edges()` for adding new edges as attributes to existing edges - in an object +- Added `mutate_edges()` for adding new edges as attributes to existing edges in an object ## Measures -- Closed #159 by fixing bug in `graph_blau_index()` -- Closed #157 by fixing bug in `graph_ei_index()` -- Closed #156 and #158 by fixing bugs with `test_random()` (defunct `test_cug()`) +- Closed #159 by fixing bug in `graph_blau_index()` +- Closed #157 by fixing bug in `graph_ei_index()` +- Closed #156 and #158 by fixing bugs with `test_random()` (defunct `test_cug()`) ## Visualisation -- Closed #148 and #153 by making all `autographr()` arguments take variable names in - quotation marks +- Closed #148 and #153 by making all `autographr()` arguments take variable names in quotation marks # migraph 0.8.6 ## Package -- Closed #75 by updating the README +- Closed #75 by updating the README ## Manipulation -- Added some functions for grabbing key information from objects - - `node_names()` for quickly accessing node labels - - `node_attribute()` for quickly accessing a certain nodal attribute - - `edge_weights()` for quickly accessing edge weights - - `graph_nodes()` for quickly accessing a count of nodes in the graph, note that for two-mode networks this will be a vector of length 2 - - `graph_edges()` for quickly accessing a count of edges in the graph - - `graph_dimensions()` is currently a copy of `graph_nodes()` -- Added some functions for adding key information to objects - - `add_node_attributes()` for adding particular nodal attributes - - `add_edge_attributes()` for adding edges from another graph - - `copy_edge_attributes()` for copying all nodal attributes from another graph -- Improved twomode and weighted handling of several functions +- Added some functions for grabbing key information from objects + - `node_names()` for quickly accessing node labels + - `node_attribute()` for quickly accessing a certain nodal attribute + - `edge_weights()` for quickly accessing edge weights + - `graph_nodes()` for quickly accessing a count of nodes in the graph, note that for two-mode networks this will be a vector of length 2 + - `graph_edges()` for quickly accessing a count of edges in the graph + - `graph_dimensions()` is currently a copy of `graph_nodes()` +- Added some functions for adding key information to objects + - `add_node_attributes()` for adding particular nodal attributes + - `add_edge_attributes()` for adding edges from another graph + - `copy_edge_attributes()` for copying all nodal attributes from another graph +- Improved twomode and weighted handling of several functions ## Measures -- Added diversity functions - - `graph_blau_index()` for summarising diversity of an attribute in a network or group - - `graph_ei_index()` for summarising diversity of an attribute over a network's ties +- Added diversity functions + - `graph_blau_index()` for summarising diversity of an attribute in a network or group + - `graph_ei_index()` for summarising diversity of an attribute over a network's ties ## Modelling -- Closed #119 by adding `node_quad_census()`, especially useful for two-mode blockmodelling -- Closed #95 and #120 by adding `graph_mixed_census()` -- Closed #97 by adding test functions - - `test_random()` carries out a conditional uniform graph (CUG) test - - `test_permutation()` carries out a quadratic assignment procedure (QAP) test +- Closed #119 by adding `node_quad_census()`, especially useful for two-mode blockmodelling +- Closed #95 and #120 by adding `graph_mixed_census()` +- Closed #97 by adding test functions + - `test_random()` carries out a conditional uniform graph (CUG) test + - `test_permutation()` carries out a quadratic assignment procedure (QAP) test ## Visualization -- Closed #135 by reexporting `aes()` from `{ggplot2}` -- Added `node_shape` option to `autographr()` +- Closed #135 by reexporting `aes()` from `{ggplot2}` +- Added `node_shape` option to `autographr()` # migraph 0.8.5 ## Package -- Updated various URLs in the vignettes to pass CRAN tests -- Reduce number of layout examples to avoid examples taking too long to run +- Updated various URLs in the vignettes to pass CRAN tests +- Reduce number of layout examples to avoid examples taking too long to run # migraph 0.8.4 ## Classes -- Closed #128 by adding `as_edgelist()` methods for converting other objects into edgelists - - Note that this currently returns a tibble -- Using `to_unnamed()` on 'network' objects now operates on them directly -- Elaborated `to_` documentation significantly -- Fixed bug in `to_onemode()` that was tripping `blockmodel()` on networks that are already one-mode -- Added `is_connected()` to test whether network is connected, `method = ` argument can be specified as `weak` or `strong` +- Closed #128 by adding `as_edgelist()` methods for converting other objects into edgelists + - Note that this currently returns a tibble +- Using `to_unnamed()` on 'network' objects now operates on them directly +- Elaborated `to_` documentation significantly +- Fixed bug in `to_onemode()` that was tripping `blockmodel()` on networks that are already one-mode +- Added `is_connected()` to test whether network is connected, `method =` argument can be specified as `weak` or `strong` ## Data -- Added `create_tree()` and `create_lattice()`, and made `create_star()` a bit faster for one-mode networks -- Added `generate_smallworld()` and `generate_scalefree()`, though only for one-mode networks currently +- Added `create_tree()` and `create_lattice()`, and made `create_star()` a bit faster for one-mode networks +- Added `generate_smallworld()` and `generate_scalefree()`, though only for one-mode networks currently ## Measures -- Added rounding to centralization measures, by default `=2` -- Closed #109 by adding centrality vignette +- Added rounding to centralization measures, by default `=2` +- Closed #109 by adding centrality vignette ## Modelling -- Added `graph_dyad_census()` for more graph profile options -- Fixed bug with `blockmodel_concor()` when an object was of class 'igraph' but not 'tbl_graph' -- Fixed bug in how `blockmodel()` was treating two-mode networks -- Closed #116 by offering both `"elbow"` and `"strict"` methods for _k_-identification - - Fixed bug in elbow method that biased heavily bipartitioned data -- Closed #131 by refactoring `ggidentify_clusters()` for speed - - Takes now roughly half the time (see issue for details) +- Added `graph_dyad_census()` for more graph profile options +- Fixed bug with `blockmodel_concor()` when an object was of class 'igraph' but not 'tbl_graph' +- Fixed bug in how `blockmodel()` was treating two-mode networks +- Closed #116 by offering both `"elbow"` and `"strict"` methods for *k*-identification + - Fixed bug in elbow method that biased heavily bipartitioned data +- Closed #131 by refactoring `ggidentify_clusters()` for speed + - Takes now roughly half the time (see issue for details) ## Visualization -- Added `ggdistrib()` for easy plotting of degree and other node score distributions -- Reexported `ggsave()`, `xlab()` and `ylab()` from `{ggplot2}` for easier plot annotation +- Added `ggdistrib()` for easy plotting of degree and other node score distributions +- Reexported `ggsave()`, `xlab()` and `ylab()` from `{ggplot2}` for easier plot annotation # migraph 0.8.3 ## Package -- Closed #108 by adding cohesion and community vignette +- Closed #108 by adding cohesion and community vignette ## Classes -- Fixed #122 by retaining edge weights from igraph in `as_matrix()` where available +- Fixed #122 by retaining edge weights from igraph in `as_matrix()` where available ## Measures -- Split `graph_equivalency()` into the same for two-mode networks and `graph_congruency() `for three-mode (two two-mode) networks -- Added option for `graph_reciprocity()` method -- Added `graph_components()` and `node_components()` +- Split `graph_equivalency()` into the same for two-mode networks and `graph_congruency()`for three-mode (two two-mode) networks +- Added option for `graph_reciprocity()` method +- Added `graph_components()` and `node_components()` ## Modelling -- Fixed #113 by retaining node labels through census functions -- Closed #114 by transposing `node_tie_census()` output so that it's consistent with `node_triad_census()` and future node_census functions -- Closed #121 by renaming `cluster_triad_census()` to `group_triad_census()` -- Added `group_tie_census()` +- Fixed #113 by retaining node labels through census functions +- Closed #114 by transposing `node_tie_census()` output so that it's consistent with `node_triad_census()` and future node_census functions +- Closed #121 by renaming `cluster_triad_census()` to `group_triad_census()` +- Added `group_tie_census()` ## Visualization -- Added option to `autographr()` for plotting convex/concave hulls -- Closed #124 by making `ggraphgrid()` a set of layout functions: - - `layout_tbl_graph_frgrid()` or `autographr(object, "frgrid")` for snapping Fruchterman-Reingold to a grid - - `layout_tbl_graph_kkgrid()` or `autographr(object, "kkgrid")` for snapping Kamada-Kawai to a grid - - `layout_tbl_graph_gogrid()` or `autographr(object, "gogrid")` for snapping graph optimisation to a grid - - `ggraphgrid()` has been deprecated +- Added option to `autographr()` for plotting convex/concave hulls +- Closed #124 by making `ggraphgrid()` a set of layout functions: + - `layout_tbl_graph_frgrid()` or `autographr(object, "frgrid")` for snapping Fruchterman-Reingold to a grid + - `layout_tbl_graph_kkgrid()` or `autographr(object, "kkgrid")` for snapping Kamada-Kawai to a grid + - `layout_tbl_graph_gogrid()` or `autographr(object, "gogrid")` for snapping graph optimisation to a grid + - `ggraphgrid()` has been deprecated ## Data -- Fixed some `ison_m182` documentation +- Fixed some `ison_m182` documentation # migraph 0.8.2 ## Package -- Fixed CRAN package check dependencies bug where 'knitr' and 'rmarkdown' were listed as Imports without being used in the package +- Fixed CRAN package check dependencies bug where 'knitr' and 'rmarkdown' were listed as Imports without being used in the package ## Classes -- Fixed bug where bipartite edge lists were not being recognised as a twomode network by `as_igraph()` -- Fixed bug where `to_uniplex()` was not returning a weighted graph +- Fixed bug where bipartite edge lists were not being recognised as a twomode network by `as_igraph()` +- Fixed bug where `to_uniplex()` was not returning a weighted graph ## Models -- Fixed bug where `blockmodel()` was not retaining node names in all parts of the object structure +- Fixed bug where `blockmodel()` was not retaining node names in all parts of the object structure ## Visualization -- Closed #107 by choosing better brewer pallette (though note this is not a very deep pallette with only 9 colors) +- Closed #107 by choosing better brewer pallette (though note this is not a very deep pallette with only 9 colors) ## Vignettes -- Expanded on the blockmodelling vignette with more intro, discussion, interpretation clues +- Expanded on the blockmodelling vignette with more intro, discussion, interpretation clues # migraph 0.8.1 ## Package -- Fixed codecov url bug -- Removed several package dependencies by moving `plot_releases()` to another package -- Made many dependencies more explicit -- Entire package 'linted' +- Fixed codecov url bug +- Removed several package dependencies by moving `plot_releases()` to another package +- Made many dependencies more explicit +- Entire package 'linted' ## Classes -- Added `is_signed()` to logically test whether the network is a signed network -- Added `to_unsigned()` for extracting networks of either "positive" or "negative" ties from a signed network -- Added `tbl_graph` methods for all other `to_` functions -- Reexported `activate()` from `{tidygraph}` +- Added `is_signed()` to logically test whether the network is a signed network +- Added `to_unsigned()` for extracting networks of either "positive" or "negative" ties from a signed network +- Added `tbl_graph` methods for all other `to_` functions +- Reexported `activate()` from `{tidygraph}` ## Visualisation -- Added sensible plotting defaults for signed networks in `autographr()` -- Removed `plot_releases()` from this package +- Added sensible plotting defaults for signed networks in `autographr()` +- Removed `plot_releases()` from this package ## Measures -- Refactored `graph_balance()` to be much faster, following David Schoch's `{signnet}` package (see that package for further extensions) +- Refactored `graph_balance()` to be much faster, following David Schoch's `{signnet}` package (see that package for further extensions) ## Data -- Updated the edge 'sign' attribute of `ison_marvel_relationships` to be a double (`-1`/`1`) to be compatible with the new `graph_balance()` and `{signnet}` +- Updated the edge 'sign' attribute of `ison_marvel_relationships` to be a double (`-1`/`1`) to be compatible with the new `graph_balance()` and `{signnet}` # migraph 0.8.0 ## Classes -- Fixed coercion to `{igraph}` from data frames and updated read script -- Added `to_main_component()` to extract the main component of a network -- Added `to_onemode()` for moving to multimodal igraph objects -- Added `to_uniplex()` method to delete edge types and their edges from - multiplex networks -- Added `to_simplex()` method to delete loops from a network -- Added `to_named()` method for randomly naming unlabeled networks + +- Fixed coercion to `{igraph}` from data frames and updated read script +- Added `to_main_component()` to extract the main component of a network +- Added `to_onemode()` for moving to multimodal igraph objects +- Added `to_uniplex()` method to delete edge types and their edges from multiplex networks +- Added `to_simplex()` method to delete loops from a network +- Added `to_named()` method for randomly naming unlabeled networks ## Data -- Added `ison_mm`, `ison_mb`, `ison_bm`, and `ison_bb` projection illustration - data -- Added `ison_karateka` community detection illustration data -- Added `ison_marvel_teams` and `ison_marvel_relationships` datasets -- Added `ison_m182` dataset of friends, social and task ties between 16 - anonymous students -- Renamed `adolescent_society` dataset to `ison_coleman`for consistency -- Data now listed at the bottom of the website References page + +- Added `ison_mm`, `ison_mb`, `ison_bm`, and `ison_bb` projection illustration data +- Added `ison_karateka` community detection illustration data +- Added `ison_marvel_teams` and `ison_marvel_relationships` datasets +- Added `ison_m182` dataset of friends, social and task ties between 16 anonymous students +- Renamed `adolescent_society` dataset to `ison_coleman`for consistency +- Data now listed at the bottom of the website References page ## Measures -- Added `graph_eigenvector()` for one mode networks -- Added `graph_balance()` for measuring structural balance -- Added `node_tie_census()`, `node_triad_census()`, `cluster_triad_census()`, - and `graph_triad_census()` -- Separated out `graph_clustering()` into the cohesion measures - `graph_density()`, `graph_reciprocity()`, `graph_transitivity()`, - and `graph_equivalence()` -- Fixed `node_smallworld()` to use separated cohesion measures + +- Added `graph_eigenvector()` for one mode networks +- Added `graph_balance()` for measuring structural balance +- Added `node_tie_census()`, `node_triad_census()`, `cluster_triad_census()`, and `graph_triad_census()` +- Separated out `graph_clustering()` into the cohesion measures `graph_density()`, `graph_reciprocity()`, `graph_transitivity()`, and `graph_equivalence()` +- Fixed `node_smallworld()` to use separated cohesion measures ## Models -- Added `blockmodel()` which masks its `{sna}` namesake but has the advantages - of working with two-mode networks and retaining node names where available - - Added `cluster_structural_equivalence()` and `cluster_regular_equivalence()` - as bases for blockmodelling - - Added `reduce_graph()` for creating a network from a blockmodel -- Added first vignette on structural holes, structural equivalence and regular - equivalence blockmodelling + +- Added `blockmodel()` which masks its `{sna}` namesake but has the advantages of working with two-mode networks and retaining node names where available + - Added `cluster_structural_equivalence()` and `cluster_regular_equivalence()` as bases for blockmodelling + - Added `reduce_graph()` for creating a network from a blockmodel +- Added first vignette on structural holes, structural equivalence and regular equivalence blockmodelling ## Visualization -- Added `autographr()` for plotting graphs with sensible defaults - - Uses a more contrastive discrete palette when some nodal attribute is given - - Uses an alpha for edges, and edges will now be sized by edge weight, where - available - - Uses node labels, sans borders, where available - - Uses different shaped nodes, and different fonts, for different node sets - - Removed `ggraphlabel()` since core functionality now provided by autographr -- Added ability for `ggidentify()` to identify the node with the highest value - of a specified node-level measure -- Added a couple of more specific visualization functions - - Added `ggatyear()` for subsetting and plotting edgelists at year - - Updated `gglineage()` to return a graph colored according to lineage - - Added tick marks -- Added several more specific functions for diagnosing and visualising - blockmodels - - Added `ggtree()` for neatly visualising hierarchical clusters - - Added `ggidentify_clusters()` for identifying which number of clusters - is most appropriate following the elbow method -- Fixed bug related to `ggraph::theme_graph()` present in a few different - visualisation functions + +- Added `autographr()` for plotting graphs with sensible defaults + - Uses a more contrastive discrete palette when some nodal attribute is given + - Uses an alpha for edges, and edges will now be sized by edge weight, where available + - Uses node labels, sans borders, where available + - Uses different shaped nodes, and different fonts, for different node sets + - Removed `ggraphlabel()` since core functionality now provided by autographr +- Added ability for `ggidentify()` to identify the node with the highest value of a specified node-level measure +- Added a couple of more specific visualization functions + - Added `ggatyear()` for subsetting and plotting edgelists at year + - Updated `gglineage()` to return a graph colored according to lineage + - Added tick marks +- Added several more specific functions for diagnosing and visualising blockmodels + - Added `ggtree()` for neatly visualising hierarchical clusters + - Added `ggidentify_clusters()` for identifying which number of clusters is most appropriate following the elbow method +- Fixed bug related to `ggraph::theme_graph()` present in a few different visualisation functions # migraph 0.7.2 ## Data -* Added `brandes` dataset for teaching centrality measures -* Added `adolescent_society` dataset for teaching friendship paradox -* Added `read_edgelist()` for importing Excel-created edgelists directly +- Added `brandes` dataset for teaching centrality measures +- Added `adolescent_society` dataset for teaching friendship paradox +- Added `read_edgelist()` for importing Excel-created edgelists directly ## Visualization -* Added `ggraphlabel()` for one-function (1F) plotting label-based network - graphs -* Added `ggevolution()` for 1F-plotting begin/end graph comparisons -* Added `ggraphgrid()` for 1F snap-to-grid graph layouts based on - Fruchterman-Reingold or Kamada-Kawai -* Added `ggidentify()` for 1F identifying nodes with maximum scores based on - some arbitrary function +- Added `ggraphlabel()` for one-function (1F) plotting label-based network graphs +- Added `ggevolution()` for 1F-plotting begin/end graph comparisons +- Added `ggraphgrid()` for 1F snap-to-grid graph layouts based on Fruchterman-Reingold or Kamada-Kawai +- Added `ggidentify()` for 1F identifying nodes with maximum scores based on some arbitrary function ## Manipulation -* Added `to_undirected()` for symmetrising networks of all types -* Made existing `to_` functions S3 methods +- Added `to_undirected()` for symmetrising networks of all types +- Made existing `to_` functions S3 methods # migraph 0.7.1 ## Classes -- Fixed Unicode char bug in coercion documentation +- Fixed Unicode char bug in coercion documentation # migraph 0.7.0 ## Classes -- Closed #100 by converting `as_` coercion functions to S3 methods +- Closed #100 by converting `as_` coercion functions to S3 methods - - Added a little more readable documentation - - Fixed bug with `as_matrix()` weighting - - Fixed bug with `as_tidygraph()` + - Added a little more readable documentation + - Fixed bug with `as_matrix()` weighting + - Fixed bug with `as_tidygraph()` ## Visualisation -- Closed #92 by adding `gglineage()` for graphing a citation network through - time -- Closed #99 by adding `ggevolution()` for graphing two timepoints of the same - network side by side -- Closed #102 by adding `ggraphgrid()` for locking a graph to a grid -- Slight improvements to `plot.igraph()` defaults +- Closed #92 by adding `gglineage()` for graphing a citation network through time +- Closed #99 by adding `ggevolution()` for graphing two timepoints of the same network side by side +- Closed #102 by adding `ggraphgrid()` for locking a graph to a grid +- Slight improvements to `plot.igraph()` defaults ## Analysis -- Added tidygraph lookups to `node_` functions +- Added tidygraph lookups to `node_` functions # migraph 0.6.6 ## Classes -- Fixed bug in `as_matrix()` with frame matrix by dropping (rarely - necessary) functionality +- Fixed bug in `as_matrix()` with frame matrix by dropping (rarely necessary) functionality - Improved handling of weights column in three-column edgelists - Improved documentation of `as_` functions ## Visualisation -- Fixed bugs in `plot_releases()` with more graceful handling of http - errors +- Fixed bugs in `plot_releases()` with more graceful handling of http errors - Added online condition to example in documentation - Specified encoding for more silent operation @@ -966,8 +956,7 @@ object when deleting weights - Added some more inter-class coercion tests -- Fixed bug in how `as_network()` sometimes coerced two-mode networks - into much larger dimension matrices +- Fixed bug in how `as_network()` sometimes coerced two-mode networks into much larger dimension matrices - Added more `is_` tests for class-independent property tests @@ -980,8 +969,7 @@ object when deleting weights - Added @csteglich 's `read_ucinet()` and `write_ucinet()` functions - `read_ucinet()` offers a file-picker when file path unknown - - `read_ucinet()` now imports to an igraph-class object by - default, with an argument to allow other alternatives + - `read_ucinet()` now imports to an igraph-class object by default, with an argument to allow other alternatives - `write_ucinet()` works with all migraph-compatible objects - Updated `mpn_bristol` documentation @@ -993,8 +981,7 @@ object when deleting weights - Renamed `sample_affiliation()` to `generate_random()` - - Rewrote `generate_random()` to be able to generate random one- - or two-mode networks + - Rewrote `generate_random()` to be able to generate random one- or two-mode networks - Updated documentation ## Models @@ -1007,8 +994,7 @@ object when deleting weights ## Package -- Reran `usethis::use_mit_license("James Hollway")`. MIT License file - now contains only the standard two lines. +- Reran `usethis::use_mit_license("James Hollway")`. MIT License file now contains only the standard two lines. - Removed `\dontrun` from examples. `netlm()` now runs in \<5 seconds. - Fixed missing website item @@ -1018,16 +1004,13 @@ object when deleting weights ## Package -- Closed \#21 by elaborating DESCRIPTION file in preparation for CRAN - submission +- Closed #21 by elaborating DESCRIPTION file in preparation for CRAN submission - Updated several old URLs in documentation ## Classes -- Closed \#85 by adding `as_network()` to coerce objects into network - class -- Modified other coercion functions to also work with network class - objects +- Closed #85 by adding `as_network()` to coerce objects into network class +- Modified other coercion functions to also work with network class objects # migraph 0.6.0 @@ -1035,16 +1018,14 @@ object when deleting weights ## Package -- Moved package's Github repository from `jhollway/` to `snlab-ch/` - organisation +- Moved package's Github repository from `jhollway/` to `snlab-ch/` organisation - Trimmed some package dependencies and added others ## Data - Elaborated documentation for the remainder of the datasets - - Now all datasets in this package are titled with whether they - are one-mode, two-mode, or three-mode + - Now all datasets in this package are titled with whether they are one-mode, two-mode, or three-mode ## Measures @@ -1052,15 +1033,10 @@ object when deleting weights ## Models -- Closed \#18 by adding `blockmodel_concor()` for employing the CONCOR - algorithm to blockmodel both one-mode and two-mode networks +- Closed #18 by adding `blockmodel_concor()` for employing the CONCOR algorithm to blockmodel both one-mode and two-mode networks - - Added a new print method for "blockmodel"-class objects based on - the `print.blockmodel()` method in the `{sna}` package that also - prints blockmodel results for two-mode networks consistently - - Added a new plot method for "blockmodel"-class objects that - leverages `{ggplot2}` for pretty plotting and that better - inherits names from the underlying object + - Added a new print method for "blockmodel"-class objects based on the `print.blockmodel()` method in the `{sna}` package that also prints blockmodel results for two-mode networks consistently + - Added a new plot method for "blockmodel"-class objects that leverages `{ggplot2}` for pretty plotting and that better inherits names from the underlying object # migraph 0.5.0 @@ -1068,21 +1044,16 @@ object when deleting weights ## Package -- Closed \#81 by making `{migraph}` depend on R versions 4.0 or above +- Closed #81 by making `{migraph}` depend on R versions 4.0 or above - Updated PR template ## Classes -- Added functions for class conversion between migraph-consistent - graph formats -- `as_matrix()` function to coerce objects into an adjacency or - incidence matrix class -- `as_igraph()` function to coerce objects into an `{igraph}` graph - class -- `as_tidygraph()` function to coerce objects into an `{tidygraph}` - tbl_graph class -- Closed \#79 by adding `is_twomode()` function to check whether - network is two-mode on all object types +- Added functions for class conversion between migraph-consistent graph formats +- `as_matrix()` function to coerce objects into an adjacency or incidence matrix class +- `as_igraph()` function to coerce objects into an `{igraph}` graph class +- `as_tidygraph()` function to coerce objects into an `{tidygraph}` tbl_graph class +- Closed #79 by adding `is_twomode()` function to check whether network is two-mode on all object types ## Data @@ -1092,45 +1063,35 @@ object when deleting weights - `mpn_powerelite` was renamed to `mpn_elite_usa_advice` - `mpn_opensecrets` was renamed to `mpn_elite_usa_money` -- Reconstructed several creation functions to take universal - (one-mode/two-mode) input: specifying `n = 5` creates a one-mode - network, while specifying `n = c(5, 5)` creates a two-mode network +- Reconstructed several creation functions to take universal (one-mode/two-mode) input: specifying `n = 5` creates a one-mode network, while specifying `n = c(5, 5)` creates a two-mode network - Added `create_empty()` - Added `create_complete()` - - Closed \#65 by extending `create_ring()` to create rings of - varying breadth - - Closed \#66 by extending `create_components()` (renamed from - `create_silos()`) to create networks with varying numbers of - components + - Closed #65 by extending `create_ring()` to create rings of varying breadth + - Closed #66 by extending `create_components()` (renamed from `create_silos()`) to create networks with varying numbers of components - Added `sample_affiliation()` for random two-mode networks - Removed `create_match()` and `create_nest()` ## Measures -- Renamed `centrality_` functions with `node_` prefix and ensured they - all also wrapped one-mode measures +- Renamed `centrality_` functions with `node_` prefix and ensured they all also wrapped one-mode measures - `centrality_degree()` renamed to `node_degree()` - `centrality_closeness()` renamed to `node_closeness()` - `centrality_betweenness()` renamed to `node_betweenness()` - - Closed \#31 by adding `node_eigenvector()` + - Closed #31 by adding `node_eigenvector()` -- Re-added `node_constraint()` for calculating Burt's constraint - measure for one- and two-mode networks +- Re-added `node_constraint()` for calculating Burt's constraint measure for one- and two-mode networks -- Re-added `node_smallworld()` for calculating Watts-Strogatz measure - of small-worldness for two-mode networks +- Re-added `node_smallworld()` for calculating Watts-Strogatz measure of small-worldness for two-mode networks -- Closed \#32 by re-adding centralization functions for one- and - two-mode networks +- Closed #32 by re-adding centralization functions for one- and two-mode networks - `graph_degree()` for degree centralization - `graph_closeness()` for closeness centralization - `graph_betweenness()` for betweenness centralization -- Re-added `graph_clustering()` for calculating (see Knoke et al - 2021): +- Re-added `graph_clustering()` for calculating (see Knoke et al 2021): - transitivity on one-mode networks - shared four-cycles on two-mode networks @@ -1138,18 +1099,14 @@ object when deleting weights ## Models -- Re-added `netlm()` for performing linear regression for multimodal - network data +- Re-added `netlm()` for performing linear regression for multimodal network data - - Closed \#76 by changing `netlm()` to accept a formula-based - input - - Closed \#77 by adding `print.summary.netlm()` for `netlm()` - regressions + - Closed #76 by changing `netlm()` to accept a formula-based input + - Closed #77 by adding `print.summary.netlm()` for `netlm()` regressions ## Visualization -- Closed \#82 by re-adding a version `plot.igraph()` with sensible - defaults for two-mode networks +- Closed #82 by re-adding a version `plot.igraph()` with sensible defaults for two-mode networks # migraph 0.4.1 @@ -1158,8 +1115,7 @@ object when deleting weights ## Package - pkgdown now deploys after release -- Reexported a number of `{igraph}` and `{tidygraph}` functions for - internal use +- Reexported a number of `{igraph}` and `{tidygraph}` functions for internal use - Completed some `convert_` and `project_` documentation ## Data @@ -1168,9 +1124,7 @@ object when deleting weights ## Analysis -- Added centrality measures that take (and if necessary return) - matrix, igraph, or tidygraph objects, and offer a correct - normalization for two-mode networks +- Added centrality measures that take (and if necessary return) matrix, igraph, or tidygraph objects, and offer a correct normalization for two-mode networks - Added `centrality_degree()` - Added `centrality_closeness()` @@ -1184,23 +1138,18 @@ object when deleting weights - Package name change from roctopus to `{migraph}` - - Closed \#50 with new logo + - Closed #50 with new logo - Now builds Linux binary too ## Manipulation -- Added `project_rows()` and `project_cols()` to make it easier to - project two-mode networks in different formats (matrix, igraph, - tidygraph) into projected versions in the same format -- Closed \#30 with conversion from different data frame formats, e.g. - weighted and unweighted edgelists, into an incidence matrix with - `as_incidence_matrix()` +- Added `project_rows()` and `project_cols()` to make it easier to project two-mode networks in different formats (matrix, igraph, tidygraph) into projected versions in the same format +- Closed #30 with conversion from different data frame formats, e.g. weighted and unweighted edgelists, into an incidence matrix with `as_incidence_matrix()` ## Data -- Renamed data related to the book "Multimodal Political Networks" - with "mpn\_" prefix +- Renamed data related to the book "Multimodal Political Networks" with "mpn\_" prefix # roctopus 0.3.0 @@ -1210,13 +1159,10 @@ object when deleting weights - Data creation updated for `{tidygraph}` defaults - - Renamed `create_lattice()` to `create_chain()` to avoid - conflicts with `tidygraph::create_lattice()` + - Renamed `create_lattice()` to `create_chain()` to avoid conflicts with `tidygraph::create_lattice()` - Renamed `create_poles()` to `create_silos()` - - Renamed `create_random()` to `play_twomode()` to avoid conflicts - with `tidygraph::play_bipartite()` - - Added export options for all `create_` and `play_` functions as - `tbl_graph` (default), `igraph`, and base matrix + - Renamed `create_random()` to `play_twomode()` to avoid conflicts with `tidygraph::play_bipartite()` + - Added export options for all `create_` and `play_` functions as `tbl_graph` (default), `igraph`, and base matrix - Updated tests for new `create_` and `play_` function names - Packaged data updated for `{tidygraph}` defaults @@ -1259,8 +1205,7 @@ object when deleting weights ## Package -- Added `row_project()` and `col_project()` functions to make it - easier to remember project directions +- Added `row_project()` and `col_project()` functions to make it easier to remember project directions # roctopus 0.2.3 @@ -1274,8 +1219,7 @@ object when deleting weights ## Package -- Added `df_to_mat()` function for converting regular adjacency and - incidence data frames into matrices +- Added `df_to_mat()` function for converting regular adjacency and incidence data frames into matrices # roctopus 0.2.1 @@ -1318,15 +1262,12 @@ object when deleting weights ## Analysis -- Added `twomode_modularity()` to calculate modularity in two-mode - networks +- Added `twomode_modularity()` to calculate modularity in two-mode networks ## Visualization -- Added `plot_multilevel()` that rotates a force-directed `igraph` - plot in three dimensions to reveal multilevel structure -- Added `plot_globalnet()` to map a multilevel network on to a - javascript, rotatable global +- Added `plot_multilevel()` that rotates a force-directed `igraph` plot in three dimensions to reveal multilevel structure +- Added `plot_globalnet()` to map a multilevel network on to a javascript, rotatable global # roctopus 0.0.3 @@ -1334,13 +1275,9 @@ object when deleting weights ## Analysis -- Added `twomode_smallworld()` to calculate observed/expected - clustering, observed/expected path-length, and the observed/expected - clustering ratio -- Added `twomode_2x2()` to identify dominance and coherence values for - networks over time -- Updated `twomode_coherence()` to allow for introduction of - second-mode attributes +- Added `twomode_smallworld()` to calculate observed/expected clustering, observed/expected path-length, and the observed/expected clustering ratio +- Added `twomode_2x2()` to identify dominance and coherence values for networks over time +- Updated `twomode_coherence()` to allow for introduction of second-mode attributes - Renamed `twomode_fragmentation()` to `twomode_components()` ## Visualisation @@ -1358,17 +1295,13 @@ object when deleting weights ## Analysis -- Added `twomode_fragmentation()` to calculate number of components in - two-mode networks and identify their membership -- Added `twomode_dominance()` to allow an nodal attribute to be passed - to the function to weight the centralization measure +- Added `twomode_fragmentation()` to calculate number of components in two-mode networks and identify their membership +- Added `twomode_dominance()` to allow an nodal attribute to be passed to the function to weight the centralization measure - Added `twomode_coherence()` to calculate Jaccard similarity ## Visualisation -- Added `plot_twomode()`, which wraps - `plot(igraph::graph_from_incidence_matrix())` with some useful - defaults +- Added `plot_twomode()`, which wraps `plot(igraph::graph_from_incidence_matrix())` with some useful defaults - coloured grayscale by default, with green/blue option - shaped circles and squares by default @@ -1386,13 +1319,9 @@ object when deleting weights ## Analysis -- Added `twomode_clustering()` to calculate percentage of three-paths - closed by four-paths +- Added `twomode_clustering()` to calculate percentage of three-paths closed by four-paths - Added `twomode_lattice()` to create two-mode lattices -- Added `twomode_centralization_degree()` to calculate degree - centralization in two-mode networks, for rows, columns, or both -- Added `twomode_centralization_between()` to calculate betweenness - centralization in two-mode networks -- Added `twomode_constraint()` to calculate network constraint in - two-mode networks +- Added `twomode_centralization_degree()` to calculate degree centralization in two-mode networks, for rows, columns, or both +- Added `twomode_centralization_between()` to calculate betweenness centralization in two-mode networks +- Added `twomode_constraint()` to calculate network constraint in two-mode networks - Added `arrange.vars()` to rearrange variables by position diff --git a/R/class_measures.R b/R/class_measures.R index 0f44efc8..4d99be6f 100644 --- a/R/class_measures.R +++ b/R/class_measures.R @@ -9,9 +9,9 @@ make_tie_measure <- function(out, object) { out } -make_graph_measure <- function(out, object) { - class(out) <- c("graph_measure", class(out)) - attr(out, "mode") <- graph_dims(object) +make_network_measure <- function(out, object) { + class(out) <- c("network_measure", class(out)) + attr(out, "mode") <- network_dims(object) out } @@ -41,7 +41,7 @@ print.tie_measure <- function(x, ..., } #' @export -print.graph_measure <- function(x, ..., +print.network_measure <- function(x, ..., digits = 3) { if (length(attr(x, "mode")) == 1) { print(as.numeric(x), digits = digits) diff --git a/R/class_motifs.R b/R/class_motifs.R index 103a023d..1b1c71fc 100644 --- a/R/class_motifs.R +++ b/R/class_motifs.R @@ -4,9 +4,9 @@ make_node_motif <- function(out, object) { out } -make_graph_motif <- function(out, object) { - class(out) <- c("graph_motif", class(out)) - attr(out, "mode") <- graph_dims(object) +make_network_motif <- function(out, object) { + class(out) <- c("network_motif", class(out)) + attr(out, "mode") <- network_dims(object) out } @@ -37,7 +37,7 @@ summary.node_motif <- function(object, ..., } #' @export -print.graph_motif <- function(x, ...) { +print.network_motif <- function(x, ...) { names <- list(names(x)) x <- as.numeric(x) mat <- matrix(x, dimnames = names) diff --git a/R/data_ison.R b/R/data_ison.R index 1c5e3072..b20e3822 100644 --- a/R/data_ison.R +++ b/R/data_ison.R @@ -194,7 +194,6 @@ #' ggsave("man/figures/isonnetworkers.png", width = 5, height = 5, dpi = "screen") #' ggsave("man/figures/isonnetworkers.pdf", width = 5, height = 5) #' ``` -#' \if{latex}{\figure{isonnetworkers.pdf}{options: width=7cm}} #' @docType data #' @keywords datasets #' @name ison_networkers diff --git a/R/make_create.R b/R/make_create.R index a288e707..443377f3 100644 --- a/R/make_create.R +++ b/R/make_create.R @@ -208,7 +208,7 @@ create_tree <- function(n, #' @export create_lattice <- function(n, directed = FALSE) { - if (is_migraph(n)) n <- graph_dims(n) + if (is_migraph(n)) n <- network_dims(n) igraph::make_lattice(n, directed = directed) } @@ -296,7 +296,7 @@ create_core <- function(n, membership = NULL) { # Helper functions ------------------ infer_n <- function(n) { - if (is_migraph(n)) n <- graph_dims(n) + if (is_migraph(n)) n <- network_dims(n) if (length(n) > 2) stop(paste("`n` should be a single integer for a one-mode network or", "a vector of two integers for a two-mode network.")) n diff --git a/R/make_generate.R b/R/make_generate.R index f258c5ea..cae0a175 100644 --- a/R/make_generate.R +++ b/R/make_generate.R @@ -29,16 +29,16 @@ NULL #' @export generate_random <- function(n, p = 0.5, directed = FALSE, with_attr = TRUE) { if(is_migraph(n)){ - m <- graph_ties(n) + m <- network_ties(n) directed <- is_directed(n) if(is_twomode(n)){ - g <- igraph::sample_bipartite(graph_dims(n)[1], - graph_dims(n)[2], + g <- igraph::sample_bipartite(network_dims(n)[1], + network_dims(n)[2], m = m, type = "gnm", directed = directed, mode = "out") } else { - g <- igraph::sample_gnm(graph_nodes(n), + g <- igraph::sample_gnm(network_nodes(n), m = m, directed = directed) } @@ -152,7 +152,7 @@ generate_permutation <- function(object, with_attr = TRUE) { # Helper functions ------------------ r1perm <- function(m) { - n <- sample(1:dim(m)[1]) + n <- sample(seq_len(dim(m)[1])) if(is_labelled(m)){ p <- matrix(data = m[n, n], nrow = dim(m)[1], ncol = dim(m)[2], dimnames = dimnames(m)) @@ -163,8 +163,8 @@ r1perm <- function(m) { } r2perm <- function(m) { - n <- sample(1:dim(m)[1]) - o <- sample(1:dim(m)[2]) + n <- sample(seq_len(dim(m)[1])) + o <- sample(seq_len(dim(m)[2])) if(is_labelled(m)){ p <- matrix(data = m[n, o], nrow = dim(m)[1], ncol = dim(m)[2], dimnames = dimnames(m)) diff --git a/R/manip_add.R b/R/manip_add.R index c7283c97..11d35ec3 100644 --- a/R/manip_add.R +++ b/R/manip_add.R @@ -19,12 +19,12 @@ NULL #' add_node_attribute(mpn_elite_usa_advice, "wealth", 1:14) #' @export add_node_attribute <- function(object, attr_name, vector){ - if(length(vector)!=graph_nodes(object)){ - if(is_twomode(object) && any(length(vector) == graph_dims(object))){ - if(length(vector) == graph_dims(object)[1]){ - vector <- c(vector, rep(NA, graph_dims(object)[2])) - } else if (length(vector) == graph_dims(object)[2]){ - vector <- c(rep(NA, graph_dims(object)[1]), vector) + if(length(vector)!=network_nodes(object)){ + if(is_twomode(object) && any(length(vector) == network_dims(object))){ + if(length(vector) == network_dims(object)[1]){ + vector <- c(vector, rep(NA, network_dims(object)[2])) + } else if (length(vector) == network_dims(object)[2]){ + vector <- c(rep(NA, network_dims(object)[1]), vector) } } else stop("Attribute vector must be same length as nodes in object.") @@ -49,7 +49,7 @@ add_tie_attribute <- function(object, attr_name, vector){ #' @describeIn add Copies node attributes from a given graph into specified graph #' @export copy_node_attributes <- function(object, object2){ - if(graph_nodes(object) != graph_nodes(object2)) + if(network_nodes(object) != network_nodes(object2)) stop("Objects need to be of compatible dimensions.") object <- as_igraph(object) object2 <- as_igraph(object2) diff --git a/R/manip_as.R b/R/manip_as.R index 53501b05..61a3da4f 100644 --- a/R/manip_as.R +++ b/R/manip_as.R @@ -474,7 +474,7 @@ as_igraph.siena <- function(object, twomode = NULL) { } } else { # add names for one-mode y - y <- add_node_attribute(y, "name", as.character(seq_len(graph_nodes(y)))) + y <- add_node_attribute(y, "name", as.character(seq_len(network_nodes(y)))) # join ties if (isTRUE(is_twomode(x))) { # x is twomode but y is onemode y <- as_edgelist(y) @@ -510,7 +510,7 @@ as_igraph.siena <- function(object, twomode = NULL) { # Add in first network as base and add names out <- object$depvars[[ddvs[1]]][,,1] # first wave if (is_twomode(out) == FALSE) { - out <- add_node_attribute(out, "name", as.character(seq_len(graph_nodes(out)))) + out <- add_node_attribute(out, "name", as.character(seq_len(network_nodes(out)))) } else { rownames(out) <- as.character(seq_len(nrow(out))) colnames(out) <- as.character(paste0("N", seq_len(ncol(out)))) diff --git a/R/manip_grab.R b/R/manip_grab.R index 8545b49e..bb2aee15 100644 --- a/R/manip_grab.R +++ b/R/manip_grab.R @@ -4,7 +4,7 @@ #' from given network data. #' They are also useful as helpers within other functions. #' -#' `graph_*()` functions always relate to the overall graph or network, +#' `network_*()` functions always relate to the overall graph or network, #' usually returning a scalar. #' `node_*()` and `tie_*()` always return vectors the same length #' as the number of nodes or edges in the network, respectively. @@ -30,7 +30,7 @@ node_mode <- function(object){ if(is_twomode(object)){ out <- igraph::get.vertex.attribute(as_igraph(object), "type") } else{ - out <- rep(FALSE, graph_nodes(object)) + out <- rep(FALSE, network_nodes(object)) } # cannot use make_node_mark here because then eternal loop class(out) <- c("node_mark", class(out)) @@ -63,7 +63,7 @@ tie_attribute <- function(object, attribute){ tie_weights <- function(object){ object <- as_igraph(object) out <- igraph::get.edge.attribute(object, "weight") - if(is.null(out)) out <- rep(1, graph_ties(object)) + if(is.null(out)) out <- rep(1, network_ties(object)) out } @@ -74,33 +74,33 @@ tie_weights <- function(object){ tie_signs <- function(object){ object <- as_igraph(object) out <- igraph::get.edge.attribute(object, "sign") - if(is.null(out)) out <- rep(1, graph_ties(object)) + if(is.null(out)) out <- rep(1, network_ties(object)) out } #' @describeIn grab Returns the total number of nodes (of any mode) in a network. #' @examples -#' graph_nodes(ison_southern_women) +#' network_nodes(ison_southern_women) #' @export -graph_nodes <- function(object){ +network_nodes <- function(object){ igraph::vcount(as_igraph(object)) } #' @describeIn grab Returns the number of edges in a network. #' @examples -#' graph_ties(ison_southern_women) +#' network_ties(ison_southern_women) #' @export -graph_ties <- function(object){ +network_ties <- function(object){ igraph::ecount(as_igraph(object)) } #' @describeIn grab Returns the dimensions of a network in a vector #' as long as the number of modes in the network. #' @examples -#' graph_dims(ison_southern_women) -#' graph_dims(to_mode1(ison_southern_women)) +#' network_dims(ison_southern_women) +#' network_dims(to_mode1(ison_southern_women)) #' @export -graph_dims <- function(object){ +network_dims <- function(object){ if(is_twomode(object)){ c(sum(!igraph::V(as_igraph(object))$type), sum(igraph::V(as_igraph(object))$type)) @@ -112,17 +112,17 @@ graph_dims <- function(object){ #' @describeIn grab Returns a vector of nodal attributes in a network #' @importFrom igraph list.vertex.attributes #' @examples -#' graph_node_attributes(mpn_elite_mex) +#' network_node_attributes(mpn_elite_mex) #' @export -graph_node_attributes <- function(object){ +network_node_attributes <- function(object){ igraph::list.vertex.attributes(as_igraph(object)) } #' @describeIn grab Returns a vector of edge attributes in a network #' @importFrom igraph list.edge.attributes #' @examples -#' graph_tie_attributes(mpn_elite_mex) +#' network_tie_attributes(mpn_elite_mex) #' @export -graph_tie_attributes <- function(object){ +network_tie_attributes <- function(object){ igraph::list.edge.attributes(as_igraph(object)) } diff --git a/R/manip_to.R b/R/manip_to.R index c2c6feda..797ebab0 100644 --- a/R/manip_to.R +++ b/R/manip_to.R @@ -318,7 +318,7 @@ to_named.tbl_graph <- function(object, names = NULL) { object <- object %>% mutate(name = names) } else { object <- object %>% mutate(name = sample(baby_names, - graph_nodes(object))) + network_nodes(object))) } object } @@ -329,7 +329,7 @@ to_named.igraph <- function(object, names = NULL) { igraph::V(object)$name <- names } else { igraph::V(object)$name <- sample(baby_names, - graph_nodes(object)) + network_nodes(object)) } object } @@ -341,9 +341,9 @@ to_named.data.frame <- function(object, names = NULL) { object[,2] <- names[as.numeric(object[,2])] } else { object[,1] <- sample(baby_names, - graph_nodes(object))[as.numeric(object[,1])] + network_nodes(object))[as.numeric(object[,1])] object[,2] <- sample(baby_names, - graph_nodes(object))[as.numeric(object[,2])] + network_nodes(object))[as.numeric(object[,2])] } object } @@ -351,7 +351,7 @@ to_named.data.frame <- function(object, names = NULL) { #' @export to_named.matrix <- function(object, names = NULL) { if(is.null(names)) names <- sample(baby_names, - graph_nodes(object)) + network_nodes(object)) if(is_twomode(object)){ rownames(object) <- names[seq_len(nrow(object))] colnames(object) <- names[(nrow(object)+1):length(names)] diff --git a/R/mark_is.R b/R/mark_is.R index 7a8b18b3..ceff017e 100644 --- a/R/mark_is.R +++ b/R/mark_is.R @@ -169,8 +169,8 @@ is_directed <- function(object) UseMethod("is_directed") #' @export is_directed.data.frame <- function(object) { - !(graph_reciprocity(object) == 0 | - graph_reciprocity(object) == 1) + !(network_reciprocity(object) == 0 | + network_reciprocity(object) == 1) } #' @export @@ -322,13 +322,13 @@ is_multiplex.matrix <- function(object){ #' @export is_multiplex.tbl_graph <- function(object){ igraph::any_multiple(object) | - length(graph_tie_attributes(object)) > 1 + length(network_tie_attributes(object)) > 1 } #' @export is_multiplex.igraph <- function(object){ igraph::any_multiple(object) | - length(graph_tie_attributes(object)) > 1 + length(network_tie_attributes(object)) > 1 } #' @export diff --git a/R/mark_nodes.R b/R/mark_nodes.R index 6d1a20fa..513188e8 100644 --- a/R/mark_nodes.R +++ b/R/mark_nodes.R @@ -31,7 +31,7 @@ node_is_cutpoint <- function(object){ "names") names(out) <- node_names(object) } else { - out <- 1:graph_nodes(object) %in% + out <- 1:network_nodes(object) %in% igraph::articulation_points(as_igraph(object)) } make_node_mark(out, object) diff --git a/R/mark_ties.R b/R/mark_ties.R index 8fb57db9..bf07dbb5 100644 --- a/R/mark_ties.R +++ b/R/mark_ties.R @@ -49,7 +49,7 @@ tie_is_reciprocated <- function(object){ #' @export tie_is_bridge <- function(object){ num_comp <- length( igraph::decompose(as_igraph(object)) ) - out <- vapply(seq_len(graph_ties(object)), function(x){ + out <- vapply(seq_len(network_ties(object)), function(x){ length( igraph::decompose(igraph::delete.edges(object, x)) ) > num_comp }, FUN.VALUE = logical(1)) if(is_labelled(object)) diff --git a/R/measure_centrality.R b/R/measure_centrality.R index 5cac35a5..caa06c37 100644 --- a/R/measure_centrality.R +++ b/R/measure_centrality.R @@ -285,7 +285,7 @@ tie_eigenvector <- function(object, normalized = TRUE){ #' @export node_reach <- function(object, normalized = TRUE, k = 2){ out <- rowSums(node_path_census(object)==k) - if(normalized) out <- out/(graph_nodes(object)-1) + if(normalized) out <- out/(network_nodes(object)-1) out <- make_node_measure(out, object) out } @@ -298,9 +298,9 @@ NULL #' @describeIn centralisation Calculate the degree centralization for a graph #' @examples -#' graph_degree(ison_southern_women, direction = "in") +#' network_degree(ison_southern_women, direction = "in") #' @export -graph_degree <- function(object, normalized = TRUE, +network_degree <- function(object, normalized = TRUE, direction = c("all", "out", "in")){ direction <- match.arg(direction) @@ -329,15 +329,15 @@ graph_degree <- function(object, normalized = TRUE, out <- igraph::centr_degree(graph = object, mode = direction, normalized = normalized)$centralization } - out <- make_graph_measure(out, object) + out <- make_network_measure(out, object) out } #' @describeIn centralisation Calculate the closeness centralization for a graph #' @examples -#' graph_closeness(ison_southern_women, direction = "in") +#' network_closeness(ison_southern_women, direction = "in") #' @export -graph_closeness <- function(object, normalized = TRUE, +network_closeness <- function(object, normalized = TRUE, direction = c("all", "out", "in")){ direction <- match.arg(direction) @@ -393,15 +393,15 @@ graph_closeness <- function(object, normalized = TRUE, mode = direction, normalized = normalized)$centralization } - out <- make_graph_measure(out, object) + out <- make_network_measure(out, object) out } #' @describeIn centralisation Calculate the betweenness centralization for a graph #' @examples -#' graph_betweenness(ison_southern_women, direction = "in") +#' network_betweenness(ison_southern_women, direction = "in") #' @export -graph_betweenness <- function(object, normalized = TRUE, +network_betweenness <- function(object, normalized = TRUE, direction = c("all", "out", "in")) { direction <- match.arg(direction) @@ -449,16 +449,16 @@ graph_betweenness <- function(object, normalized = TRUE, } else { out <- igraph::centr_betw(graph = graph)$centralization } - out <- make_graph_measure(out, object) + out <- make_network_measure(out, object) out } #' @describeIn centralisation Calculate the eigenvector centralization for a graph #' @examples -#' graph_eigenvector(mpn_elite_mex) -#' graph_eigenvector(ison_southern_women) +#' network_eigenvector(mpn_elite_mex) +#' network_eigenvector(ison_southern_women) #' @export -graph_eigenvector <- function(object, normalized = TRUE){ +network_eigenvector <- function(object, normalized = TRUE){ if (is_twomode(object)) { out <- c(igraph::centr_eigen(as_igraph(to_mode1(object)), normalized = normalized)$centralization, @@ -468,7 +468,7 @@ graph_eigenvector <- function(object, normalized = TRUE){ out <- igraph::centr_eigen(as_igraph(object), normalized = normalized)$centralization } - out <- make_graph_measure(out, object) + out <- make_network_measure(out, object) out } diff --git a/R/measure_closure.R b/R/measure_closure.R index a3cea195..414596cf 100644 --- a/R/measure_closure.R +++ b/R/measure_closure.R @@ -4,12 +4,12 @@ #' in one-, two-, and three-mode networks. #' @details #' For one-mode networks, shallow wrappers of igraph versions exist via -#' `graph_reciprocity` and `graph_transitivity`. +#' `network_reciprocity` and `network_transitivity`. #' -#' For two-mode networks, `graph_equivalency` calculates the proportion of three-paths in the network +#' For two-mode networks, `network_equivalency` calculates the proportion of three-paths in the network #' that are closed by fourth tie to establish a "shared four-cycle" structure. #' -#' For three-mode networks, `graph_congruency` calculates the proportion of three-paths +#' For three-mode networks, `network_congruency` calculates the proportion of three-paths #' spanning two two-mode networks that are closed by a fourth tie to establish a #' "congruent four-cycle" structure. #' @param object A one-mode or two-mode matrix, igraph, or tidygraph @@ -33,29 +33,29 @@ NULL #' @describeIn closure Calculate reciprocity in a (usually directed) network #' @importFrom igraph reciprocity #' @examples -#' graph_reciprocity(ison_southern_women) +#' network_reciprocity(ison_southern_women) #' @export -graph_reciprocity <- function(object, method = "default") { - make_graph_measure(igraph::reciprocity(as_igraph(object), mode = method), +network_reciprocity <- function(object, method = "default") { + make_network_measure(igraph::reciprocity(as_igraph(object), mode = method), object) } #' @describeIn closure Calculate transitivity in a network #' @importFrom igraph transitivity #' @examples -#' graph_transitivity(ison_southern_women) +#' network_transitivity(ison_southern_women) #' @export -graph_transitivity <- function(object) { - make_graph_measure(igraph::transitivity(as_igraph(object)), +network_transitivity <- function(object) { + make_network_measure(igraph::transitivity(as_igraph(object)), object) } #' @describeIn closure Calculate equivalence or reinforcement #' in a (usually two-mode) network #' @examples -#' graph_equivalency(ison_southern_women) +#' network_equivalency(ison_southern_women) #' @export -graph_equivalency <- function(object) { +network_equivalency <- function(object) { if (is_twomode(object)) { mat <- as_matrix(object) c <- ncol(mat) @@ -68,12 +68,12 @@ graph_equivalency <- function(object) { (matrix(indegrees, c, c) - twopaths))) if (is.nan(output)) output <- 1 } else stop("This function expects a two-mode network") - make_graph_measure(output, object) + make_network_measure(output, object) } #' @describeIn closure Calculate congruency across two two-mode networks #' @export -graph_congruency <- function(object, object2){ +network_congruency <- function(object, object2){ if(missing(object) | missing(object2)) stop("This function expects two two-mode networks") mat1 <- as_matrix(object) mat2 <- as_matrix(object2) @@ -91,6 +91,6 @@ graph_congruency <- function(object, object2){ sum(twopaths * (matrix(degrees, c, c) - twopaths))) if (is.nan(output)) output <- 1 - make_graph_measure(output, object) + make_network_measure(output, object) } diff --git a/R/measure_cohesion.R b/R/measure_cohesion.R index 8c007fa6..babe5bcb 100644 --- a/R/measure_cohesion.R +++ b/R/measure_cohesion.R @@ -11,17 +11,17 @@ NULL #' to the number of possible ties. #' @importFrom igraph edge_density #' @examples -#' graph_density(mpn_elite_mex) -#' graph_density(mpn_elite_usa_advice) +#' network_density(mpn_elite_mex) +#' network_density(mpn_elite_usa_advice) #' @export -graph_density <- function(object) { +network_density <- function(object) { if (is_twomode(object)) { mat <- as_matrix(object) out <- sum(mat) / (nrow(mat) * ncol(mat)) } else { out <- igraph::edge_density(as_igraph(object)) } - make_graph_measure(out, object) + make_network_measure(out, object) } #' @describeIn cohesion Returns number of (strong) components in the network. @@ -29,9 +29,9 @@ graph_density <- function(object) { #' please use `to_undirected()` first. #' @importFrom igraph components #' @export -graph_components <- function(object){ +network_components <- function(object){ object <- as_igraph(object) - make_graph_measure(igraph::components(object, mode = "strong")$no, + make_network_measure(igraph::components(object, mode = "strong")$no, object) } @@ -43,11 +43,11 @@ graph_components <- function(object){ #' "The Cohesiveness of Blocks In Social Networks: Node Connectivity and Conditional Density." #' _Sociological Methodology_ 31(1): 305-59. #' @examples -#' graph_cohesion(ison_marvel_relationships) -#' graph_cohesion(to_giant(ison_marvel_relationships)) +#' network_cohesion(ison_marvel_relationships) +#' network_cohesion(to_giant(ison_marvel_relationships)) #' @export -graph_cohesion <- function(object){ - make_graph_measure(igraph::cohesion(as_igraph(object)), +network_cohesion <- function(object){ + make_network_measure(igraph::cohesion(as_igraph(object)), object) } @@ -55,23 +55,23 @@ graph_cohesion <- function(object){ #' to remove from the network to increase the number of components. #' @importFrom igraph adhesion #' @examples -#' graph_adhesion(ison_marvel_relationships) -#' graph_adhesion(to_giant(ison_marvel_relationships)) +#' network_adhesion(ison_marvel_relationships) +#' network_adhesion(to_giant(ison_marvel_relationships)) #' @export -graph_adhesion <- function(object){ - make_graph_measure(igraph::adhesion(as_igraph(object)), +network_adhesion <- function(object){ + make_network_measure(igraph::adhesion(as_igraph(object)), object) } #' @describeIn cohesion Returns the maximum path length in the network. #' @importFrom igraph diameter #' @examples -#' graph_diameter(ison_marvel_relationships) -#' graph_diameter(to_giant(ison_marvel_relationships)) +#' network_diameter(ison_marvel_relationships) +#' network_diameter(to_giant(ison_marvel_relationships)) #' @export -graph_diameter <- function(object){ +network_diameter <- function(object){ object <- as_igraph(object) - make_graph_measure(igraph::diameter(object, + make_network_measure(igraph::diameter(object, directed = is_directed(object)), object) } @@ -79,12 +79,12 @@ graph_diameter <- function(object){ #' @describeIn cohesion Returns the average path length in the network. #' @importFrom igraph mean_distance #' @examples -#' graph_length(ison_marvel_relationships) -#' graph_length(to_giant(ison_marvel_relationships)) +#' network_length(ison_marvel_relationships) +#' network_length(to_giant(ison_marvel_relationships)) #' @export -graph_length <- function(object){ +network_length <- function(object){ object <- as_igraph(object) - make_graph_measure(igraph::mean_distance(object, + make_network_measure(igraph::mean_distance(object, directed = is_directed(object)), object) } diff --git a/R/measure_diversity.R b/R/measure_diversity.R index 2cdb99f8..29a031a2 100644 --- a/R/measure_diversity.R +++ b/R/measure_diversity.R @@ -13,7 +13,7 @@ NULL #' @describeIn diversity Calculates the heterogeneity of ties across a network or #' within clusters by node attributes. -#' @section graph_diversity: +#' @section network_diversity: #' Blau's index (1977) uses a formula known also in other disciplines #' by other names #' (Gini-Simpson Index, Gini impurity, Gini's diversity index, @@ -33,11 +33,11 @@ NULL #' New York: Free Press. #' @examples #' marvel_friends <- to_unsigned(ison_marvel_relationships, "positive") -#' graph_diversity(marvel_friends, "Gender") -#' graph_diversity(marvel_friends, "Attractive") -#' graph_diversity(marvel_friends, "Gender", "Rich") +#' network_diversity(marvel_friends, "Gender") +#' network_diversity(marvel_friends, "Attractive") +#' network_diversity(marvel_friends, "Gender", "Rich") #' @export -graph_diversity <- function(object, attribute, clusters = NULL){ +network_diversity <- function(object, attribute, clusters = NULL){ blau <- function(features) { 1 - sum((table(features)/length(features))^2) } attr <- node_attribute(object, attribute) if (is.null(clusters)) { @@ -55,12 +55,12 @@ graph_diversity <- function(object, attribute, clusters = NULL){ names(blauout) <- paste0("Cluster ", unique(clu)) blauout <- blauout[order(names(blauout))] } else stop("`clusters` must be the name of a nodal variable in the object.") - make_graph_measure(blauout, object) + make_network_measure(blauout, object) } #' @describeIn diversity Calculates the embeddedness of a node within the group #' of nodes of the same attribute -#' @section graph_homophily: +#' @section network_homophily: #' Given a partition of a network into a number of mutually exclusive groups then #' The E-I index is the number of ties between (or _external_) nodes #' grouped in some mutually exclusive categories @@ -73,10 +73,10 @@ graph_diversity <- function(object, attribute, clusters = NULL){ #' Informal networks and organizational crises: an experimental simulation. #' _Social Psychology Quarterly_ 51(2), 123-140. #' @examples -#' graph_homophily(marvel_friends, "Gender") -#' graph_homophily(marvel_friends, "Attractive") +#' network_homophily(marvel_friends, "Gender") +#' network_homophily(marvel_friends, "Attractive") #' @export -graph_homophily <- function(object, attribute){ +network_homophily <- function(object, attribute){ m <- as_matrix(object) if (length(attribute) == 1 && is.character(attribute)) { attribute <- node_attribute(object, attribute) @@ -88,16 +88,16 @@ graph_homophily <- function(object, attribute){ nInternal <- sum(m * same) nExternal <- sum(m) - nInternal ei <- (nExternal - nInternal) / sum(m) - make_graph_measure(ei, object) + make_network_measure(ei, object) } #' @describeIn diversity Calculates the degree assortativity in a graph. #' @importFrom igraph assortativity_degree #' @examples -#' graph_assortativity(mpn_elite_mex) +#' network_assortativity(mpn_elite_mex) #' @export -graph_assortativity <- function(object){ - make_graph_measure(igraph::assortativity_degree(as_igraph(object), +network_assortativity <- function(object){ + make_network_measure(igraph::assortativity_degree(as_igraph(object), directed = is_directed(object)), object) } diff --git a/R/measure_features.R b/R/measure_features.R index 89ef71b6..57500fe9 100644 --- a/R/measure_features.R +++ b/R/measure_features.R @@ -8,35 +8,35 @@ NULL #' @describeIn features Returns correlation between a given network #' and a core-periphery model with the same dimensions. #' @examples -#' graph_core(ison_adolescents) -#' graph_core(ison_southern_women) +#' network_core(ison_adolescents) +#' network_core(ison_southern_women) #' @references #' Borgatti, Stephen P., and Martin G. Everett. 2000. #' “Models of Core/Periphery Structures.” #' _Social Networks_ 21(4):375–95. #' \doi{10.1016/S0378-8733(99)00019-2} #' @export -graph_core <- function(object, +network_core <- function(object, membership = NULL){ if(is.null(membership)) membership <- node_core(object) out <- stats::cor(c(as_matrix(object)), c(as_matrix(create_core(object, membership = membership)))) - make_graph_measure(out, object) + make_network_measure(out, object) } #' @describeIn features Returns correlation between a given network #' and a component model with the same dimensions. #' @examples -#' graph_factions(ison_adolescents) -#' graph_factions(ison_southern_women) +#' network_factions(ison_adolescents) +#' network_factions(ison_southern_women) #' @export -graph_factions <- function(object, +network_factions <- function(object, membership = NULL){ out <- stats::cor(c(as_matrix(object)), c(as_matrix(create_components(object, membership = membership)))) - make_graph_measure(out, object) + make_network_measure(out, object) } #' @describeIn features Returns modularity of one- or two-mode networks @@ -44,9 +44,9 @@ graph_factions <- function(object, #' @param resolution A proportion indicating the resolution scale. #' By default 1. #' @examples -#' graph_modularity(ison_adolescents, +#' network_modularity(ison_adolescents, #' node_kernighanlin(ison_adolescents)) -#' graph_modularity(ison_southern_women, +#' network_modularity(ison_southern_women, #' node_kernighanlin(ison_southern_women)) #' @references #' Murata, Tsuyoshi. 2010. Modularity for Bipartite Networks. @@ -55,15 +55,15 @@ graph_factions <- function(object, #' Springer, Boston, MA. #' \doi{10.1007/978-1-4419-6287-4_7} #' @export -graph_modularity <- function(object, +network_modularity <- function(object, membership = NULL, resolution = 1){ if(!is_graph(object)) object <- as_igraph(object) if(is_twomode(object)){ - make_graph_measure(igraph::modularity(to_multilevel(object), + make_network_measure(igraph::modularity(to_multilevel(object), membership = membership, resolution = resolution), object) - } else make_graph_measure(igraph::modularity(object, + } else make_network_measure(igraph::modularity(object, membership = membership, resolution = resolution), object) @@ -75,9 +75,9 @@ graph_modularity <- function(object, #' have short path lengths. #' @param times Integer of number of simulations. #' @examples -#' graph_smallworld(ison_brandes) -#' graph_smallworld(ison_southern_women) -#' @seealso [graph_transitivity()] and [graph_equivalency()] +#' network_smallworld(ison_brandes) +#' network_smallworld(ison_southern_women) +#' @seealso [network_transitivity()] and [network_equivalency()] #' for how clustering is calculated #' @references #' Watts, Duncan J., and Steven H. Strogatz. 1998. @@ -85,26 +85,26 @@ graph_modularity <- function(object, #' _Nature_ 393(6684):440–42. #' \doi{10.1038/30918}. #' @export -graph_smallworld <- function(object, times = 100) { +network_smallworld <- function(object, times = 100) { if(is_twomode(object)){ - obsclust <- graph_equivalency(object) + obsclust <- network_equivalency(object) expclust <- mean(vapply(1:times, - function(x) graph_equivalency(generate_random(object)), + function(x) network_equivalency(generate_random(object)), FUN.VALUE = numeric(1))) } else { - obsclust <- graph_transitivity(object) + obsclust <- network_transitivity(object) expclust <- mean(vapply(1:times, - function(x) graph_transitivity(generate_random(object)), + function(x) network_transitivity(generate_random(object)), FUN.VALUE = numeric(1))) } - obspath <- graph_length(object) + obspath <- network_length(object) exppath <- mean(vapply(1:times, - function(x) graph_length(generate_random(object)), + function(x) network_length(generate_random(object)), FUN.VALUE = numeric(1))) - make_graph_measure((obsclust/expclust)/(obspath/exppath), + make_network_measure((obsclust/expclust)/(obspath/exppath), object) } @@ -114,9 +114,9 @@ graph_smallworld <- function(object, times = 100) { #' `1` if all triangles are balanced. #' @source `{signnet}` by David Schoch #' @examples -#' graph_balance(ison_marvel_relationships) +#' network_balance(ison_marvel_relationships) #' @export -graph_balance <- function(object) { +network_balance <- function(object) { count_signed_triangles <- function(object){ g <- as_igraph(object) @@ -171,6 +171,6 @@ graph_balance <- function(object) { stop("sign may only contain -1 and 1") } tria_count <- count_signed_triangles(g) - make_graph_measure(unname((tria_count["+++"] + tria_count["+--"])/sum(tria_count)), + make_network_measure(unname((tria_count["+++"] + tria_count["+--"])/sum(tria_count)), object) } diff --git a/R/member_community.R b/R/member_community.R index d337b8e6..6b91c306 100644 --- a/R/member_community.R +++ b/R/member_community.R @@ -18,7 +18,7 @@ NULL #' @export node_kernighanlin <- function(object){ # assign groups arbitrarily - n <- graph_nodes(object) + n <- network_nodes(object) group_size <- ifelse(n %% 2 == 0, n/2, (n+1)/2) # count internal and external costs of each vertex diff --git a/R/member_core.R b/R/member_core.R index d815d94b..77f0d36f 100644 --- a/R/member_core.R +++ b/R/member_core.R @@ -26,24 +26,24 @@ #' mpn_elite_usa_advice %>% as_tidygraph %>% #' mutate(corep = node_core(mpn_elite_usa_advice)) %>% #' autographr(node_color = "corep") -#' graph_core(mpn_elite_usa_advice) +#' network_core(mpn_elite_usa_advice) #' @export node_core <- function(object){ if(is_directed(object)) warning("Asymmetric core-periphery not yet implemented.") if(is_weighted(object)) warning("Weighted core-periphery not yet implemented.") degi <- node_degree(object, normalized = FALSE) nord <- order(degi, decreasing = TRUE) - zbest <- graph_nodes(object)*3 + zbest <- network_nodes(object)*3 kbest <- 0 z <- 1/2*sum(degi) - for(k in 1:(graph_nodes(object)-1)){ + for(k in 1:(network_nodes(object)-1)){ z <- z + k - 1 - degi[nord][k] if(z < zbest){ zbest <- z kbest <- k } } - out <- ifelse(seq_len(graph_nodes(object)) %in% nord[seq_len(kbest)], + out <- ifelse(seq_len(network_nodes(object)) %in% nord[seq_len(kbest)], 1,2) if(is_labelled(object)) names(out) <- node_names(object) make_node_member(out, object) diff --git a/R/member_equivalence.R b/R/member_equivalence.R index c9c0328d..afa8a30c 100644 --- a/R/member_equivalence.R +++ b/R/member_equivalence.R @@ -142,7 +142,7 @@ node_automorphic_equivalence <- function(object, k_strict <- function(hc, object){ zero_merged <- hc$merge[round(hc$height,4) == 0,] - k <- nrow(zero_merged) + graph_nodes(object) - sum(zero_merged < 0) + sum(zero_merged > 0) + k <- nrow(zero_merged) + network_nodes(object) - sum(zero_merged < 0) + sum(zero_merged > 0) k } @@ -187,7 +187,7 @@ k_elbow <- function(hc, object, census, range){ x_max_dist } - vertices <- graph_nodes(object) + vertices <- network_nodes(object) observedcorrelation <- cor(t(census)) resultlist <- list() @@ -215,8 +215,8 @@ k_elbow <- function(hc, object, census, range){ } k_silhouette <- function(hc, object, range){ - kcs <- 2:min(range, graph_nodes(object)) - ns <- seq_len(graph_nodes(object)) + kcs <- 2:min(range, network_nodes(object)) + ns <- seq_len(network_nodes(object)) distances <- hc$distances ks <- vector() for(kc in kcs){ diff --git a/R/migraph-defunct.R b/R/migraph-defunct.R index 1bf50268..f87956b3 100644 --- a/R/migraph-defunct.R +++ b/R/migraph-defunct.R @@ -110,17 +110,33 @@ edge_reciprocal <- function(object){ #' @describeIn defunct Deprecated on 2022-06-28. #' @export graph_edge_attributes <- function(object){ - .Deprecated("graph_tie_attributes", package = "migraph", + .Deprecated("network_tie_attributes", package = "migraph", old = "graph_edge_attributes") - graph_tie_attributes(object) + network_tie_attributes(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_tie_attributes <- function(object){ + .Deprecated("network_tie_attributes", package = "migraph", + old = "graph_tie_attributes") + network_tie_attributes(object) } #' @describeIn defunct Deprecated on 2022-06-28. #' @export graph_edges <- function(object){ - .Deprecated("graph_ties", package = "migraph", + .Deprecated("network_ties", package = "migraph", old = "graph_edges") - graph_ties(object) + network_ties(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_ties <- function(object){ + .Deprecated("network_ties", package = "migraph", + old = "graph_ties") + network_ties(object) } #' @describeIn defunct Deprecated on 2022-06-30. @@ -158,15 +174,289 @@ to_main_component <- function(object) { #' @describeIn defunct Deprecated on 2022-09-10. #' @export graph_blau_index <- function(object, attribute, clusters = NULL) { - .Deprecated("graph_diversity", package = "migraph", + .Deprecated("network_diversity", package = "migraph", old = "graph_blau_index") - graph_diversity(object, attribute, clusters) + network_diversity(object, attribute = attribute, clusters = clusters) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_diversity <- function(object, attribute, clusters = NULL) { + .Deprecated("network_diversity", package = "migraph", + old = "graph_diversity") + network_diversity(object, attribute = attribute, clusters = clusters) } #' @describeIn defunct Deprecated on 2022-09-10. #' @export graph_ei_index <- function(object, attribute) { - .Deprecated("graph_homophily", package = "migraph", + .Deprecated("network_homophily", package = "migraph", old = "graph_ei_index") - graph_homophily(object, attribute) + network_homophily(object, attribute = attribute) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_homophily <- function(object, attribute) { + .Deprecated("network_homophily", package = "migraph", + old = "graph_homophily") + network_homophily(object, attribute = attribute) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +plot.graph_test <- function(x, ..., + threshold = .95, + tails = c("two", "one")) { + .Deprecated("plot.network_test", package = "migraph", + old = "plot.graph_test") + plot.network_test(x, ..., + threshold = threshold, + tails = tails) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +print.graph_test <- function(x, ..., + max.length = 6, + digits = 3) { + .Deprecated("print.network_test", package = "migraph", + old = "print.graph_test") + print.network_test(x, ..., + max.length = max.length, + digits = digits) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +print.graph_measure <- function(x, ..., + digits = 3) { + .Deprecated("print.network_measure", package = "migraph", + old = "print.graph_measure") + print.network_measure(x, ..., + digits = digits) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +print.graph_motif <- function(x, ...) { + .Deprecated("print.network_motif", package = "migraph", + old = "print.graph_motif") + print.network_motif(x, ...) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_adhesion <- function(object) { + .Deprecated("network_adhesion", package = "migraph", + old = "graph_adhesion") + network_adhesion(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_cohesion <- function(object) { + .Deprecated("network_cohesion", package = "migraph", + old = "graph_cohesion") + network_cohesion(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_assortativity <- function(object) { + .Deprecated("network_assortativity", package = "migraph", + old = "graph_assortativity") + network_assortativity(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_balance <- function(object) { + .Deprecated("network_balance", package = "migraph", + old = "graph_balance") + network_balance(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_betweenness <- function(object, normalized = TRUE, + direction = c("all", "out", "in")) { + .Deprecated("network_betweenness", package = "migraph", + old = "graph_betweenness") + network_betweenness(object, normalized = normalized, + direction = direction) } + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_closeness <- function(object, normalized = TRUE, + direction = c("all", "out", "in")) { + .Deprecated("network_closeness", package = "migraph", + old = "graph_closeness") + network_closeness(object, normalized = normalized, + direction = direction) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_degree <- function(object, normalized = TRUE, + direction = c("all", "out", "in")) { + .Deprecated("network_degree", package = "migraph", + old = "graph_degree") + network_degree(object, normalized = normalized, + direction = direction) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_eigenvector <- function(object, normalized = TRUE) { + .Deprecated("network_eigenvector", package = "migraph", + old = "graph_eigenvector") + network_eigenvector(object, normalized = normalized) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_components <- function(object) { + .Deprecated("network_components", package = "migraph", + old = "graph_components") + network_components(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_factions <- function(object, membership = NULL) { + .Deprecated("network_factions", package = "migraph", + old = "graph_factions") + network_factions(object, membership = membership) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_congruency <- function(object, object2) { + .Deprecated("network_congruency", package = "migraph", + old = "graph_congruency") + network_congruency(object, object2) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_equivalency <- function(object) { + .Deprecated("network_equivalency", package = "migraph", + old = "graph_equivalency") + network_equivalency(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_core <- function(object, membership = NULL) { + .Deprecated("network_core", package = "migraph", + old = "graph_core") + network_core(object, membership = membership) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_density <- function(object) { + .Deprecated("network_density", package = "migraph", + old = "graph_density") + network_density(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_reciprocity <- function(object, method = "default") { + .Deprecated("network_reciprocity", package = "migraph", + old = "graph_reciprocity") + network_reciprocity(object, method = method) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_transitivity <- function(object) { + .Deprecated("network_transitivity", package = "migraph", + old = "graph_transitivity") + network_transitivity(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_diameter <- function(object) { + .Deprecated("network_diameter", package = "migraph", + old = "graph_diameter") + network_diameter(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_length <- function(object) { + .Deprecated("network_length", package = "migraph", + old = "graph_length") + network_length(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_dims <- function(object) { + .Deprecated("network_dims", package = "migraph", + old = "graph_dims") + network_dims(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_nodes <- function(object) { + .Deprecated("network_nodes", package = "migraph", + old = "graph_nodes") + network_nodes(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_dyad_census <- function(object) { + .Deprecated("network_dyad_census", package = "migraph", + old = "graph_dyad_census") + network_dyad_census(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_triad_census <- function(object) { + .Deprecated("network_triad_census", package = "migraph", + old = "graph_triad_census") + network_triad_census(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_mixed_census <- function(object, object2) { + .Deprecated("network_mixed_census", package = "migraph", + old = "graph_mixed_census") + network_mixed_census(object, object2) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_modularity <- function(object, membership = NULL, resolution = 1) { + .Deprecated("network_modularity", package = "migraph", + old = "graph_modularity") + network_modularity(object, membership = membership, + resolution = resolution) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_node_attributes <- function(object) { + .Deprecated("network_node_attributes", package = "migraph", + old = "graph_node_attributes") + network_node_attributes(object) +} + +#' @describeIn defunct Deprecated on 2022-09-25. +#' @export +graph_smallworld <- function(object, times = 100) { + .Deprecated("network_smallworld", package = "migraph", + old = "graph_smallworld") + network_smallworld(object, times = times) +} + diff --git a/R/model_cluster.R b/R/model_cluster.R index 29a50337..72f8120e 100644 --- a/R/model_cluster.R +++ b/R/model_cluster.R @@ -85,7 +85,7 @@ cluster_concor <- function(object, census){ c(t(cbind(t(utils::combn(g, 2)), p))) } )) merges <- c(merges, - list(c(t(cbind(t(utils::combn(seq_len(graph_nodes(object)), 2)), 0))))) + list(c(t(cbind(t(utils::combn(seq_len(network_nodes(object)), 2)), 0))))) merged <- matrix(unlist(merges), ncol = 3, byrow = TRUE) merged <- merged[!duplicated(merged[,1:2]),] merged[,3] <- abs(merged[,3] - max(merged[,3])) diff --git a/R/model_regression.R b/R/model_regression.R index 49d9a5f9..bd6ad3f1 100644 --- a/R/model_regression.R +++ b/R/model_regression.R @@ -393,7 +393,7 @@ convertToMatrixList <- function(formula, data){ names(out) <- paste(IV[[elem]], collapse = " ") out <- out } else { - if (IV[[elem]][1] %in% graph_tie_attributes(data)){ + if (IV[[elem]][1] %in% network_tie_attributes(data)){ out <- as_matrix(to_uniplex(data, edge = IV[[elem]][1])) out <- list(out) diff --git a/R/model_tests.R b/R/model_tests.R index 4bf66124..5ee1b73f 100644 --- a/R/model_tests.R +++ b/R/model_tests.R @@ -16,7 +16,7 @@ NULL #' marvel_friends <- to_unsigned(ison_marvel_relationships) #' marvel_friends <- to_giant(marvel_friends) %>% #' to_subgraph(PowerOrigin == "Human") -#' (cugtest <- test_random(marvel_friends, graph_homophily, attribute = "Attractive", +#' (cugtest <- test_random(marvel_friends, network_homophily, attribute = "Attractive", #' times = 200)) #' plot(cugtest) #' @export @@ -30,8 +30,8 @@ test_random <- function(object, FUN, ..., } else { obsd <- FUN(object) } - n <- graph_nodes(object) - d <- graph_density(object) + n <- network_nodes(object) + d <- network_density(object) future::plan(strategy) rands <- furrr::future_map(1:times, generate_random, n = n, p = d, .progress = verbose, @@ -58,14 +58,14 @@ test_random <- function(object, FUN, ..., plteobs = mean(simd <= obsd), pgteobs = mean(simd >= obsd), reps = times) - class(out) <- "graph_test" + class(out) <- "network_test" out } #' @describeIn tests Returns test results for some measure on an object #' against a distribution of measures on permutations of the original network #' @examples #' (qaptest <- test_permutation(marvel_friends, -#' graph_homophily, attribute = "Attractive", +#' network_homophily, attribute = "Attractive", #' times = 200)) #' plot(qaptest) #' @export @@ -79,8 +79,8 @@ test_permutation <- function(object, FUN, ..., } else { obsd <- FUN(object) } - n <- graph_nodes(object) - d <- graph_density(object) + n <- network_nodes(object) + d <- network_density(object) future::plan(strategy) rands <- furrr::future_map(1:times, function(x) as_igraph(generate_permutation(object)), @@ -105,12 +105,12 @@ test_permutation <- function(object, FUN, ..., plteobs = mean(simd <= obsd), pgteobs = mean(simd >= obsd), reps = times) - class(out) <- "graph_test" + class(out) <- "network_test" out } #' @export -print.graph_test <- function(x, ..., +print.network_test <- function(x, ..., max.length = 6, digits = 3){ cat(paste("\n", x$test, "Test Results\n\n")) @@ -120,7 +120,7 @@ print.graph_test <- function(x, ..., } #' @export -plot.graph_test <- function(x, ..., +plot.network_test <- function(x, ..., threshold = .95, tails = c("two", "one")){ data <- data.frame(Statistic = x$testdist) diff --git a/R/motif_census.R b/R/motif_census.R index 3b9c86f7..72fe33f5 100644 --- a/R/motif_census.R +++ b/R/motif_census.R @@ -178,17 +178,17 @@ node_path_census <- function(object){ #' Censuses of graphs' motifs #' -#' @name graph_census +#' @name network_census #' @family motifs #' @param object A migraph-consistent object. #' @param object2 A second, two-mode migraph-consistent object. NULL -#' @describeIn graph_census Returns a census of dyad motifs in a network +#' @describeIn network_census Returns a census of dyad motifs in a network #' @examples -#' graph_dyad_census(ison_adolescents) +#' network_dyad_census(ison_adolescents) #' @export -graph_dyad_census <- function(object) { +network_dyad_census <- function(object) { if (is_twomode(object)) { stop("A twomode or multilevel option for a dyad census is not yet implemented.") } else { @@ -196,18 +196,18 @@ graph_dyad_census <- function(object) { out <- unlist(out) names(out) <- c("Mutual", "Asymmetric", "Null") if (!is_directed(object)) out <- out[c(1, 3)] - make_graph_motif(out, object) + make_network_motif(out, object) } } -#' @describeIn graph_census Returns a census of triad motifs in a network +#' @describeIn network_census Returns a census of triad motifs in a network #' @references #' Davis, James A., and Samuel Leinhardt. 1967. #' “\href{https://files.eric.ed.gov/fulltext/ED024086.pdf}{The Structure of Positive Interpersonal Relations in Small Groups}.” 55. #' @examples -#' graph_triad_census(ison_adolescents) +#' network_triad_census(ison_adolescents) #' @export -graph_triad_census <- function(object) { +network_triad_census <- function(object) { if (is_twomode(object)) { stop("A twomode or multilevel option for a triad census is not yet implemented.") } else { @@ -217,11 +217,11 @@ graph_triad_census <- function(object) { "030T", "030C", "201", "120D", "120U", "120C", "210", "300") if (!is_directed(object)) out <- out[c(1, 2, 3, 11, 15, 16)] - make_graph_motif(out, object) + make_network_motif(out, object) } } -#' @describeIn graph_census Returns a census of triad motifs that span +#' @describeIn network_census Returns a census of triad motifs that span #' a one-mode and a two-mode network #' @source Alejandro Espinosa 'netmem' #' @references @@ -231,12 +231,12 @@ graph_triad_census <- function(object) { #' \doi{10.1017/nws.2017.8} #' @examples #' marvel_friends <- to_unsigned(ison_marvel_relationships, "positive") -#' (mixed_cen <- graph_mixed_census(marvel_friends, ison_marvel_teams)) +#' (mixed_cen <- network_mixed_census(marvel_friends, ison_marvel_teams)) #' @export -graph_mixed_census <- function (object, object2) { +network_mixed_census <- function (object, object2) { if(is_twomode(object)) stop("First object should be a one-mode network") if(!is_twomode(object2)) stop("Second object should be a two-mode network") - if(graph_dims(object)[1]!=graph_dims(object2)[1]) stop("Non-conformable arrays") + if(network_dims(object)[1]!=network_dims(object2)[1]) stop("Non-conformable arrays") m1 <- as_matrix(object) m2 <- as_matrix(object2) @@ -269,5 +269,5 @@ graph_mixed_census <- function (object, object2) { "02" = sum(onemode.reciprocal * bipartite.null) / 2, "01" = sum(onemode.forward * bipartite.null) / 2 + sum(onemode.backward * bipartite.null) / 2, "00" = sum(onemode.null * bipartite.null) / 2) - make_graph_motif(res, object) + make_network_motif(res, object) } diff --git a/R/viz_autographr.R b/R/viz_autographr.R index a6a24af4..066b1f0b 100644 --- a/R/viz_autographr.R +++ b/R/viz_autographr.R @@ -291,7 +291,7 @@ autographr <- auto_graph <- function(object, nsize <- node_size(g) } } else { - nsize <- ifelse(graph_nodes(g) <= 10, 5, (100 / graph_nodes(g)) / 2) + nsize <- ifelse(network_nodes(g) <= 10, 5, (100 / network_nodes(g)) / 2) } if (!is.null(node_shape)) { diff --git a/R/viz_gglineage.R b/R/viz_gglineage.R index 80e578d5..409364c8 100644 --- a/R/viz_gglineage.R +++ b/R/viz_gglineage.R @@ -28,7 +28,7 @@ gglineage <- function(object, labels = TRUE){ } lo <- ggraph::create_layout(object, layout = "alluvial") if (!is.null(lo$year)) lo$x = lo$year else - if ("year" %in% graph_node_attributes(object)) lo$x = node_attribute(object, "year") + if ("year" %in% network_node_attributes(object)) lo$x = node_attribute(object, "year") if (is.null(lo$name)) lo$name = node_names(object) g <- ggraph::ggraph(object, graph = lo) + ggraph::geom_edge_diagonal(aes(edge_color = as.factor(.data$from)), diff --git a/R/viz_layout_partition.R b/R/viz_layout_partition.R index 9027c3ee..bed062d1 100644 --- a/R/viz_layout_partition.R +++ b/R/viz_layout_partition.R @@ -104,7 +104,7 @@ layout_tbl_graph_concentric <- function(object, membership = NULL, radius = NULL stop("Duplicated nodes in layers!") if(is_labelled(object)) all_n <- node_names(object) else - all_n <- 1:graph_nodes(object) + all_n <- 1:network_nodes(object) sel_other <- all_n[!all_n %in% all_c] if (length(sel_other) > 0) membership[[length(membership) + 1]] <- sel_other @@ -166,7 +166,8 @@ getNNvec <- function(object, members){ diag(diss) <- NA if(is_labelled(object)) starts <- names(sort(node_degree(object)[circle], decreasing = TRUE)[1]) - else starts <- paste0("V",1:graph_nodes(object))[sort(node_degree(object)[circle], decreasing = TRUE)[1]] + else starts <- paste0("V",1:network_nodes(object))[sort(node_degree(object)[circle], + decreasing = TRUE)[1]] if(length(circle)>1) starts <- c(starts, names(which.min(diss[starts,]))) out <- starts diff --git a/README.Rmd b/README.Rmd index f9330a78..ba4ad43a 100644 --- a/README.Rmd +++ b/README.Rmd @@ -30,6 +30,8 @@ list_data <- function(string){ [![Codecov test coverage](https://codecov.io/gh/snlab-ch/migraph/branch/main/graph/badge.svg)](https://app.codecov.io/gh/snlab-ch/migraph?branch=main) [![CodeFactor](https://www.codefactor.io/repository/github/snlab-ch/migraph/badge)](https://www.codefactor.io/repository/github/snlab-ch/migraph) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4559/badge)](https://bestpractices.coreinfrastructure.org/projects/4559) +[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7076396.svg)](https://doi.org/10.5281/zenodo.7076396) + @@ -135,16 +137,16 @@ with existing function names wherever possible. #### Measures - Centrality: `node_degree()`, `node_closeness()`, `node_betweenness()`, and `node_eigenvector()` -- Centralization: `graph_degree()`, `graph_closeness()`, `graph_betweenness()`, and `graph_eigenvector()` -- Cohesion: `graph_density()`, `graph_reciprocity()`, `graph_transitivity()`, `graph_equivalency()`, and `graph_congruency()` -- Connectedness: `graph_components()`, `graph_cohesion()`, `graph_adhesion()`, `graph_diameter()`, `graph_length()` -- Diversity: `graph_diversity()`, `graph_homophily()`, `graph_assortativity()` +- Centralization: `network_degree()`, `network_closeness()`, `network_betweenness()`, and `network_eigenvector()` +- Cohesion: `network_density()`, `network_reciprocity()`, `network_transitivity()`, `network_equivalency()`, and `network_congruency()` +- Connectedness: `network_components()`, `network_cohesion()`, `network_adhesion()`, `network_diameter()`, `network_length()` +- Diversity: `network_diversity()`, `network_homophily()`, `network_assortativity()` - Structural holes: e.g. `node_redundancy()`, `node_effsize()`, `node_efficiency()`, `node_constraint()`, `node_hierarchy()` -- Topological features: e.g. `graph_core()`, `graph_factions()`, `graph_modularity()`, `graph_smallworld()`, `graph_balance()` +- Topological features: e.g. `network_core()`, `network_factions()`, `network_modularity()`, `network_smallworld()`, `network_balance()` #### Motifs -- Censuses: `r list_functions("node_.*_census")`, `r list_functions("graph_.*_census")` +- Censuses: `r list_functions("node_.*_census")`, `r list_functions("network_.*_census")` #### Models @@ -154,8 +156,26 @@ with existing function names wherever possible. #### Visualization -- `autographr()` for plotting graphs with sensible defaults based on their properties -- New layouts: `r list_functions("^layout_")` for snapping a layout to a grid +- `autographr()` for one-line plotting graphs with sensible defaults based on their properties +- New layouts for snapping a layout to a grid or for visualizing partitions: + +```{r layout-comparison, echo = FALSE, message=FALSE} +library(migraph) +library(igraph) +library(gridBase) +library(grid) + +par(mfrow=c(1, 2), mai = c(0,0,0.5,0)) +plot(as_igraph(mpn_elite_usa_advice), layout = layout_as_bipartite, main = "{igraph} bipartite") +## the last one is the current plot +plot.new() ## suggested by @Josh +vps <- baseViewports() +pushViewport(vps$figure) ## I am in the space of the autocorrelation plot +vp1 <-plotViewport(c(1.8,1,0,1)) ## create new vp with margins, you play with this values +p <- autographr(mpn_elite_usa_advice, "hierarchy") + ggtitle("{migraph} layout") +print(p,vp = vp1) +``` + - Class-based plots: e.g. `plot.matrix()`, `plot.members()`, `plot.node_measure()` Please explore [the list of functions](https://snlab-ch.github.io/migraph/reference/index.html) to find out more. diff --git a/README.md b/README.md index c204a009..ba05d94a 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ coverage](https://codecov.io/gh/snlab-ch/migraph/branch/main/graph/badge.svg)](h [![CodeFactor](https://www.codefactor.io/repository/github/snlab-ch/migraph/badge)](https://www.codefactor.io/repository/github/snlab-ch/migraph) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4559/badge)](https://bestpractices.coreinfrastructure.org/projects/4559) +[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7076396.svg)](https://doi.org/10.5281/zenodo.7076396) + @@ -141,25 +143,25 @@ function names wherever possible. - Centrality: `node_degree()`, `node_closeness()`, `node_betweenness()`, and `node_eigenvector()` -- Centralization: `graph_degree()`, `graph_closeness()`, - `graph_betweenness()`, and `graph_eigenvector()` -- Cohesion: `graph_density()`, `graph_reciprocity()`, - `graph_transitivity()`, `graph_equivalency()`, and - `graph_congruency()` -- Connectedness: `graph_components()`, `graph_cohesion()`, - `graph_adhesion()`, `graph_diameter()`, `graph_length()` -- Diversity: `graph_diversity()`, `graph_homophily()`, - `graph_assortativity()` +- Centralization: `network_degree()`, `network_closeness()`, + `network_betweenness()`, and `network_eigenvector()` +- Cohesion: `network_density()`, `network_reciprocity()`, + `network_transitivity()`, `network_equivalency()`, and + `network_congruency()` +- Connectedness: `network_components()`, `network_cohesion()`, + `network_adhesion()`, `network_diameter()`, `network_length()` +- Diversity: `network_diversity()`, `network_homophily()`, + `network_assortativity()` - Structural holes: e.g. `node_redundancy()`, `node_effsize()`, `node_efficiency()`, `node_constraint()`, `node_hierarchy()` -- Topological features: e.g. `graph_core()`, `graph_factions()`, - `graph_modularity()`, `graph_smallworld()`, `graph_balance()` +- Topological features: e.g. `network_core()`, `network_factions()`, + `network_modularity()`, `network_smallworld()`, `network_balance()` #### Motifs - Censuses: `node_path_census()`, `node_quad_census()`, - `node_tie_census()`, `node_triad_census()`, `graph_dyad_census()`, - `graph_mixed_census()`, `graph_triad_census()` + `node_tie_census()`, `node_triad_census()`, `network_dyad_census()`, + `network_mixed_census()`, `network_triad_census()` #### Models @@ -172,14 +174,13 @@ function names wherever possible. #### Visualization -- `autographr()` for plotting graphs with sensible defaults based on - their properties -- New layouts: `layout_tbl_graph_alluvial()`, - `layout_tbl_graph_concentric()`, `layout_tbl_graph_frgrid()`, - `layout_tbl_graph_gogrid()`, `layout_tbl_graph_hierarchy()`, - `layout_tbl_graph_kkgrid()`, `layout_tbl_graph_ladder()`, - `layout_tbl_graph_railway()`, `layout_tbl_graph_stressgrid()` for - snapping a layout to a grid +- `autographr()` for one-line plotting graphs with sensible defaults + based on their properties +- New layouts for snapping a layout to a grid or for visualizing + partitions: + + + - Class-based plots: e.g. `plot.matrix()`, `plot.members()`, `plot.node_measure()` diff --git a/man/centralisation.Rd b/man/centralisation.Rd index 779fa5dc..7730d383 100644 --- a/man/centralisation.Rd +++ b/man/centralisation.Rd @@ -2,19 +2,23 @@ % Please edit documentation in R/measure_centrality.R \name{centralisation} \alias{centralisation} -\alias{graph_degree} -\alias{graph_closeness} -\alias{graph_betweenness} -\alias{graph_eigenvector} +\alias{network_degree} +\alias{network_closeness} +\alias{network_betweenness} +\alias{network_eigenvector} \title{Measures of network centralisation} \usage{ -graph_degree(object, normalized = TRUE, direction = c("all", "out", "in")) +network_degree(object, normalized = TRUE, direction = c("all", "out", "in")) -graph_closeness(object, normalized = TRUE, direction = c("all", "out", "in")) +network_closeness(object, normalized = TRUE, direction = c("all", "out", "in")) -graph_betweenness(object, normalized = TRUE, direction = c("all", "out", "in")) +network_betweenness( + object, + normalized = TRUE, + direction = c("all", "out", "in") +) -graph_eigenvector(object, normalized = TRUE) +network_eigenvector(object, normalized = TRUE) } \arguments{ \item{object}{An object of a migraph-consistent class: @@ -44,21 +48,21 @@ Measures of network centralisation } \section{Functions}{ \itemize{ -\item \code{graph_degree()}: Calculate the degree centralization for a graph +\item \code{network_degree()}: Calculate the degree centralization for a graph -\item \code{graph_closeness()}: Calculate the closeness centralization for a graph +\item \code{network_closeness()}: Calculate the closeness centralization for a graph -\item \code{graph_betweenness()}: Calculate the betweenness centralization for a graph +\item \code{network_betweenness()}: Calculate the betweenness centralization for a graph -\item \code{graph_eigenvector()}: Calculate the eigenvector centralization for a graph +\item \code{network_eigenvector()}: Calculate the eigenvector centralization for a graph }} \examples{ -graph_degree(ison_southern_women, direction = "in") -graph_closeness(ison_southern_women, direction = "in") -graph_betweenness(ison_southern_women, direction = "in") -graph_eigenvector(mpn_elite_mex) -graph_eigenvector(ison_southern_women) +network_degree(ison_southern_women, direction = "in") +network_closeness(ison_southern_women, direction = "in") +network_betweenness(ison_southern_women, direction = "in") +network_eigenvector(mpn_elite_mex) +network_eigenvector(ison_southern_women) } \seealso{ Other measures: diff --git a/man/closure.Rd b/man/closure.Rd index 5ec1d69c..553d4494 100644 --- a/man/closure.Rd +++ b/man/closure.Rd @@ -2,19 +2,19 @@ % Please edit documentation in R/measure_closure.R \name{closure} \alias{closure} -\alias{graph_reciprocity} -\alias{graph_transitivity} -\alias{graph_equivalency} -\alias{graph_congruency} +\alias{network_reciprocity} +\alias{network_transitivity} +\alias{network_equivalency} +\alias{network_congruency} \title{Measures of network closure} \usage{ -graph_reciprocity(object, method = "default") +network_reciprocity(object, method = "default") -graph_transitivity(object) +network_transitivity(object) -graph_equivalency(object) +network_equivalency(object) -graph_congruency(object, object2) +network_congruency(object, object2) } \arguments{ \item{object}{A one-mode or two-mode matrix, igraph, or tidygraph} @@ -30,31 +30,31 @@ in one-, two-, and three-mode networks. } \details{ For one-mode networks, shallow wrappers of igraph versions exist via -\code{graph_reciprocity} and \code{graph_transitivity}. +\code{network_reciprocity} and \code{network_transitivity}. -For two-mode networks, \code{graph_equivalency} calculates the proportion of three-paths in the network +For two-mode networks, \code{network_equivalency} calculates the proportion of three-paths in the network that are closed by fourth tie to establish a "shared four-cycle" structure. -For three-mode networks, \code{graph_congruency} calculates the proportion of three-paths +For three-mode networks, \code{network_congruency} calculates the proportion of three-paths spanning two two-mode networks that are closed by a fourth tie to establish a "congruent four-cycle" structure. } \section{Functions}{ \itemize{ -\item \code{graph_reciprocity()}: Calculate reciprocity in a (usually directed) network +\item \code{network_reciprocity()}: Calculate reciprocity in a (usually directed) network -\item \code{graph_transitivity()}: Calculate transitivity in a network +\item \code{network_transitivity()}: Calculate transitivity in a network -\item \code{graph_equivalency()}: Calculate equivalence or reinforcement +\item \code{network_equivalency()}: Calculate equivalence or reinforcement in a (usually two-mode) network -\item \code{graph_congruency()}: Calculate congruency across two two-mode networks +\item \code{network_congruency()}: Calculate congruency across two two-mode networks }} \examples{ -graph_reciprocity(ison_southern_women) -graph_transitivity(ison_southern_women) -graph_equivalency(ison_southern_women) +network_reciprocity(ison_southern_women) +network_transitivity(ison_southern_women) +network_equivalency(ison_southern_women) } \references{ Robins, Garry L, and Malcolm Alexander. 2004. diff --git a/man/cohesion.Rd b/man/cohesion.Rd index 5362d689..9a51bf29 100644 --- a/man/cohesion.Rd +++ b/man/cohesion.Rd @@ -2,25 +2,25 @@ % Please edit documentation in R/measure_cohesion.R \name{cohesion} \alias{cohesion} -\alias{graph_density} -\alias{graph_components} -\alias{graph_cohesion} -\alias{graph_adhesion} -\alias{graph_diameter} -\alias{graph_length} +\alias{network_density} +\alias{network_components} +\alias{network_cohesion} +\alias{network_adhesion} +\alias{network_diameter} +\alias{network_length} \title{Measures of network cohesion or connectedness} \usage{ -graph_density(object) +network_density(object) -graph_components(object) +network_components(object) -graph_cohesion(object) +network_cohesion(object) -graph_adhesion(object) +network_adhesion(object) -graph_diameter(object) +network_diameter(object) -graph_length(object) +network_length(object) } \arguments{ \item{object}{An object of a migraph-consistent class: @@ -38,35 +38,35 @@ and the number of nodes or edges to remove that would increase fragmentation. } \section{Functions}{ \itemize{ -\item \code{graph_density()}: summarises the ratio of ties +\item \code{network_density()}: summarises the ratio of ties to the number of possible ties. -\item \code{graph_components()}: Returns number of (strong) components in the network. +\item \code{network_components()}: Returns number of (strong) components in the network. To get the 'weak' components of a directed graph, please use \code{to_undirected()} first. -\item \code{graph_cohesion()}: Returns the minimum number of nodes to remove +\item \code{network_cohesion()}: Returns the minimum number of nodes to remove from the network needed to increase the number of components. -\item \code{graph_adhesion()}: Returns the minimum number of edges needed +\item \code{network_adhesion()}: Returns the minimum number of edges needed to remove from the network to increase the number of components. -\item \code{graph_diameter()}: Returns the maximum path length in the network. +\item \code{network_diameter()}: Returns the maximum path length in the network. -\item \code{graph_length()}: Returns the average path length in the network. +\item \code{network_length()}: Returns the average path length in the network. }} \examples{ -graph_density(mpn_elite_mex) -graph_density(mpn_elite_usa_advice) -graph_cohesion(ison_marvel_relationships) -graph_cohesion(to_giant(ison_marvel_relationships)) -graph_adhesion(ison_marvel_relationships) -graph_adhesion(to_giant(ison_marvel_relationships)) -graph_diameter(ison_marvel_relationships) -graph_diameter(to_giant(ison_marvel_relationships)) -graph_length(ison_marvel_relationships) -graph_length(to_giant(ison_marvel_relationships)) +network_density(mpn_elite_mex) +network_density(mpn_elite_usa_advice) +network_cohesion(ison_marvel_relationships) +network_cohesion(to_giant(ison_marvel_relationships)) +network_adhesion(ison_marvel_relationships) +network_adhesion(to_giant(ison_marvel_relationships)) +network_diameter(ison_marvel_relationships) +network_diameter(to_giant(ison_marvel_relationships)) +network_length(ison_marvel_relationships) +network_length(to_giant(ison_marvel_relationships)) } \references{ White, Douglas R and Frank Harary. 2001. diff --git a/man/core-periphery.Rd b/man/core-periphery.Rd index e9439f8c..53653b43 100644 --- a/man/core-periphery.Rd +++ b/man/core-periphery.Rd @@ -33,7 +33,7 @@ it ignores ties between these blocks. mpn_elite_usa_advice \%>\% as_tidygraph \%>\% mutate(corep = node_core(mpn_elite_usa_advice)) \%>\% autographr(node_color = "corep") -graph_core(mpn_elite_usa_advice) +network_core(mpn_elite_usa_advice) } \references{ Borgatti, Stephen P., & Everett, Martin G. 1999. diff --git a/man/defunct.Rd b/man/defunct.Rd index 8a44dcf1..5c2a9406 100644 --- a/man/defunct.Rd +++ b/man/defunct.Rd @@ -15,13 +15,47 @@ \alias{edge_bridges} \alias{edge_reciprocal} \alias{graph_edge_attributes} +\alias{graph_tie_attributes} \alias{graph_edges} +\alias{graph_ties} \alias{node_cuts} \alias{to_edges} \alias{join_edges} \alias{to_main_component} \alias{graph_blau_index} +\alias{graph_diversity} \alias{graph_ei_index} +\alias{graph_homophily} +\alias{plot.graph_test} +\alias{print.graph_test} +\alias{print.graph_measure} +\alias{print.graph_motif} +\alias{graph_adhesion} +\alias{graph_cohesion} +\alias{graph_assortativity} +\alias{graph_balance} +\alias{graph_betweenness} +\alias{graph_closeness} +\alias{graph_degree} +\alias{graph_eigenvector} +\alias{graph_components} +\alias{graph_factions} +\alias{graph_congruency} +\alias{graph_equivalency} +\alias{graph_core} +\alias{graph_density} +\alias{graph_reciprocity} +\alias{graph_transitivity} +\alias{graph_diameter} +\alias{graph_length} +\alias{graph_dims} +\alias{graph_nodes} +\alias{graph_dyad_census} +\alias{graph_triad_census} +\alias{graph_mixed_census} +\alias{graph_modularity} +\alias{graph_node_attributes} +\alias{graph_smallworld} \title{Functions that have been renamed, superseded, or are no longer working} \usage{ add_edge_attribute(object, attr_name, vector) @@ -50,8 +84,12 @@ edge_reciprocal(object) graph_edge_attributes(object) +graph_tie_attributes(object) + graph_edges(object) +graph_ties(object) + node_cuts(object) to_edges(object) @@ -62,7 +100,71 @@ to_main_component(object) graph_blau_index(object, attribute, clusters = NULL) +graph_diversity(object, attribute, clusters = NULL) + graph_ei_index(object, attribute) + +graph_homophily(object, attribute) + +\method{plot}{graph_test}(x, ..., threshold = 0.95, tails = c("two", "one")) + +\method{print}{graph_test}(x, ..., max.length = 6, digits = 3) + +\method{print}{graph_measure}(x, ..., digits = 3) + +\method{print}{graph_motif}(x, ...) + +graph_adhesion(object) + +graph_cohesion(object) + +graph_assortativity(object) + +graph_balance(object) + +graph_betweenness(object, normalized = TRUE, direction = c("all", "out", "in")) + +graph_closeness(object, normalized = TRUE, direction = c("all", "out", "in")) + +graph_degree(object, normalized = TRUE, direction = c("all", "out", "in")) + +graph_eigenvector(object, normalized = TRUE) + +graph_components(object) + +graph_factions(object, membership = NULL) + +graph_congruency(object, object2) + +graph_equivalency(object) + +graph_core(object, membership = NULL) + +graph_density(object) + +graph_reciprocity(object, method = "default") + +graph_transitivity(object) + +graph_diameter(object) + +graph_length(object) + +graph_dims(object) + +graph_nodes(object) + +graph_dyad_census(object) + +graph_triad_census(object) + +graph_mixed_census(object, object2) + +graph_modularity(object, membership = NULL, resolution = 1) + +graph_node_attributes(object) + +graph_smallworld(object, times = 100) } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} @@ -101,8 +203,12 @@ wherever possible and update your scripts accordingly. \item \code{graph_edge_attributes()}: Deprecated on 2022-06-28. +\item \code{graph_tie_attributes()}: Deprecated on 2022-09-25. + \item \code{graph_edges()}: Deprecated on 2022-06-28. +\item \code{graph_ties()}: Deprecated on 2022-09-25. + \item \code{node_cuts()}: Deprecated on 2022-06-30. \item \code{to_edges()}: Deprecated on 2022-06-28. @@ -113,7 +219,71 @@ wherever possible and update your scripts accordingly. \item \code{graph_blau_index()}: Deprecated on 2022-09-10. +\item \code{graph_diversity()}: Deprecated on 2022-09-25. + \item \code{graph_ei_index()}: Deprecated on 2022-09-10. +\item \code{graph_homophily()}: Deprecated on 2022-09-25. + +\item \code{plot(graph_test)}: Deprecated on 2022-09-25. + +\item \code{print(graph_test)}: Deprecated on 2022-09-25. + +\item \code{print(graph_measure)}: Deprecated on 2022-09-25. + +\item \code{print(graph_motif)}: Deprecated on 2022-09-25. + +\item \code{graph_adhesion()}: Deprecated on 2022-09-25. + +\item \code{graph_cohesion()}: Deprecated on 2022-09-25. + +\item \code{graph_assortativity()}: Deprecated on 2022-09-25. + +\item \code{graph_balance()}: Deprecated on 2022-09-25. + +\item \code{graph_betweenness()}: Deprecated on 2022-09-25. + +\item \code{graph_closeness()}: Deprecated on 2022-09-25. + +\item \code{graph_degree()}: Deprecated on 2022-09-25. + +\item \code{graph_eigenvector()}: Deprecated on 2022-09-25. + +\item \code{graph_components()}: Deprecated on 2022-09-25. + +\item \code{graph_factions()}: Deprecated on 2022-09-25. + +\item \code{graph_congruency()}: Deprecated on 2022-09-25. + +\item \code{graph_equivalency()}: Deprecated on 2022-09-25. + +\item \code{graph_core()}: Deprecated on 2022-09-25. + +\item \code{graph_density()}: Deprecated on 2022-09-25. + +\item \code{graph_reciprocity()}: Deprecated on 2022-09-25. + +\item \code{graph_transitivity()}: Deprecated on 2022-09-25. + +\item \code{graph_diameter()}: Deprecated on 2022-09-25. + +\item \code{graph_length()}: Deprecated on 2022-09-25. + +\item \code{graph_dims()}: Deprecated on 2022-09-25. + +\item \code{graph_nodes()}: Deprecated on 2022-09-25. + +\item \code{graph_dyad_census()}: Deprecated on 2022-09-25. + +\item \code{graph_triad_census()}: Deprecated on 2022-09-25. + +\item \code{graph_mixed_census()}: Deprecated on 2022-09-25. + +\item \code{graph_modularity()}: Deprecated on 2022-09-25. + +\item \code{graph_node_attributes()}: Deprecated on 2022-09-25. + +\item \code{graph_smallworld()}: Deprecated on 2022-09-25. + }} \keyword{internal} diff --git a/man/diversity.Rd b/man/diversity.Rd index 11aa4d1f..c726f18a 100644 --- a/man/diversity.Rd +++ b/man/diversity.Rd @@ -2,16 +2,16 @@ % Please edit documentation in R/measure_diversity.R \name{diversity} \alias{diversity} -\alias{graph_diversity} -\alias{graph_homophily} -\alias{graph_assortativity} +\alias{network_diversity} +\alias{network_homophily} +\alias{network_assortativity} \title{Measures of network diversity} \usage{ -graph_diversity(object, attribute, clusters = NULL) +network_diversity(object, attribute, clusters = NULL) -graph_homophily(object, attribute) +network_homophily(object, attribute) -graph_assortativity(object) +network_assortativity(object) } \arguments{ \item{object}{An object of a migraph-consistent class: @@ -35,16 +35,16 @@ across this attribute. } \section{Functions}{ \itemize{ -\item \code{graph_diversity()}: Calculates the heterogeneity of ties across a network or +\item \code{network_diversity()}: Calculates the heterogeneity of ties across a network or within clusters by node attributes. -\item \code{graph_homophily()}: Calculates the embeddedness of a node within the group +\item \code{network_homophily()}: Calculates the embeddedness of a node within the group of nodes of the same attribute -\item \code{graph_assortativity()}: Calculates the degree assortativity in a graph. +\item \code{network_assortativity()}: Calculates the degree assortativity in a graph. }} -\section{graph_diversity}{ +\section{network_diversity}{ Blau's index (1977) uses a formula known also in other disciplines by other names @@ -61,7 +61,7 @@ The maximum value depends on the number of categories and whether nodes can be evenly distributed across categories. } -\section{graph_homophily}{ +\section{network_homophily}{ Given a partition of a network into a number of mutually exclusive groups then The E-I index is the number of ties between (or \emph{external}) nodes @@ -74,12 +74,12 @@ where 1 indicates ties only between categories/groups and -1 ties only within ca \examples{ marvel_friends <- to_unsigned(ison_marvel_relationships, "positive") -graph_diversity(marvel_friends, "Gender") -graph_diversity(marvel_friends, "Attractive") -graph_diversity(marvel_friends, "Gender", "Rich") -graph_homophily(marvel_friends, "Gender") -graph_homophily(marvel_friends, "Attractive") -graph_assortativity(mpn_elite_mex) +network_diversity(marvel_friends, "Gender") +network_diversity(marvel_friends, "Attractive") +network_diversity(marvel_friends, "Gender", "Rich") +network_homophily(marvel_friends, "Gender") +network_homophily(marvel_friends, "Attractive") +network_assortativity(mpn_elite_mex) } \references{ Blau, Peter M. (1977). diff --git a/man/features.Rd b/man/features.Rd index 760015a9..10bfd365 100644 --- a/man/features.Rd +++ b/man/features.Rd @@ -2,25 +2,25 @@ % Please edit documentation in R/measure_features.R \name{features} \alias{features} -\alias{graph_core} -\alias{graph_factions} -\alias{graph_modularity} -\alias{graph_smallworld} -\alias{graph_balance} +\alias{network_core} +\alias{network_factions} +\alias{network_modularity} +\alias{network_smallworld} +\alias{network_balance} \title{Measures of network topological features} \source{ \code{{signnet}} by David Schoch } \usage{ -graph_core(object, membership = NULL) +network_core(object, membership = NULL) -graph_factions(object, membership = NULL) +network_factions(object, membership = NULL) -graph_modularity(object, membership = NULL, resolution = 1) +network_modularity(object, membership = NULL, resolution = 1) -graph_smallworld(object, times = 100) +network_smallworld(object, times = 100) -graph_balance(object) +network_balance(object) } \arguments{ \item{object}{An object of a migraph-consistent class: @@ -44,38 +44,38 @@ Measures of network topological features } \section{Functions}{ \itemize{ -\item \code{graph_core()}: Returns correlation between a given network +\item \code{network_core()}: Returns correlation between a given network and a core-periphery model with the same dimensions. -\item \code{graph_factions()}: Returns correlation between a given network +\item \code{network_factions()}: Returns correlation between a given network and a component model with the same dimensions. -\item \code{graph_modularity()}: Returns modularity of one- or two-mode networks +\item \code{network_modularity()}: Returns modularity of one- or two-mode networks based on nodes' membership in pre-defined clusters. -\item \code{graph_smallworld()}: Returns small-world metrics for one- and +\item \code{network_smallworld()}: Returns small-world metrics for one- and two-mode networks. Small-world networks can be highly clustered and yet have short path lengths. -\item \code{graph_balance()}: Returns the structural balance index on +\item \code{network_balance()}: Returns the structural balance index on the proportion of balanced triangles, ranging between \code{0} if all triangles are imbalanced and \code{1} if all triangles are balanced. }} \examples{ -graph_core(ison_adolescents) -graph_core(ison_southern_women) -graph_factions(ison_adolescents) -graph_factions(ison_southern_women) -graph_modularity(ison_adolescents, +network_core(ison_adolescents) +network_core(ison_southern_women) +network_factions(ison_adolescents) +network_factions(ison_southern_women) +network_modularity(ison_adolescents, node_kernighanlin(ison_adolescents)) -graph_modularity(ison_southern_women, +network_modularity(ison_southern_women, node_kernighanlin(ison_southern_women)) -graph_smallworld(ison_brandes) -graph_smallworld(ison_southern_women) -graph_balance(ison_marvel_relationships) +network_smallworld(ison_brandes) +network_smallworld(ison_southern_women) +network_balance(ison_marvel_relationships) } \references{ Borgatti, Stephen P., and Martin G. Everett. 2000. @@ -95,7 +95,7 @@ Watts, Duncan J., and Steven H. Strogatz. 1998. \doi{10.1038/30918}. } \seealso{ -\code{\link[=graph_transitivity]{graph_transitivity()}} and \code{\link[=graph_equivalency]{graph_equivalency()}} +\code{\link[=network_transitivity]{network_transitivity()}} and \code{\link[=network_equivalency]{network_equivalency()}} for how clustering is calculated Other measures: diff --git a/man/figures/README-layout-comparison-1.png b/man/figures/README-layout-comparison-1.png new file mode 100644 index 00000000..009c977d Binary files /dev/null and b/man/figures/README-layout-comparison-1.png differ diff --git a/man/figures/isonnetworkers.pdf b/man/figures/isonnetworkers.pdf deleted file mode 100644 index a28a38b3..00000000 Binary files a/man/figures/isonnetworkers.pdf and /dev/null differ diff --git a/man/figures/isonnetworkers.png b/man/figures/isonnetworkers.png deleted file mode 100644 index 6579b923..00000000 Binary files a/man/figures/isonnetworkers.png and /dev/null differ diff --git a/man/grab.Rd b/man/grab.Rd index 4c7ca541..b8814430 100644 --- a/man/grab.Rd +++ b/man/grab.Rd @@ -8,11 +8,11 @@ \alias{tie_attribute} \alias{tie_weights} \alias{tie_signs} -\alias{graph_nodes} -\alias{graph_ties} -\alias{graph_dims} -\alias{graph_node_attributes} -\alias{graph_tie_attributes} +\alias{network_nodes} +\alias{network_ties} +\alias{network_dims} +\alias{network_node_attributes} +\alias{network_tie_attributes} \title{Grab various node or edge attributes from a network} \usage{ node_names(object) @@ -27,15 +27,15 @@ tie_weights(object) tie_signs(object) -graph_nodes(object) +network_nodes(object) -graph_ties(object) +network_ties(object) -graph_dims(object) +network_dims(object) -graph_node_attributes(object) +network_node_attributes(object) -graph_tie_attributes(object) +network_tie_attributes(object) } \arguments{ \item{object}{An object of a migraph-consistent class: @@ -54,7 +54,7 @@ These functions operate to help extract certain attributes from given network data. They are also useful as helpers within other functions. -\verb{graph_*()} functions always relate to the overall graph or network, +\verb{network_*()} functions always relate to the overall graph or network, usually returning a scalar. \verb{node_*()} and \verb{tie_*()} always return vectors the same length as the number of nodes or edges in the network, respectively. @@ -73,16 +73,16 @@ as the number of nodes or edges in the network, respectively. \item \code{tie_signs()}: Extracts the signs of the edges in a network. -\item \code{graph_nodes()}: Returns the total number of nodes (of any mode) in a network. +\item \code{network_nodes()}: Returns the total number of nodes (of any mode) in a network. -\item \code{graph_ties()}: Returns the number of edges in a network. +\item \code{network_ties()}: Returns the number of edges in a network. -\item \code{graph_dims()}: Returns the dimensions of a network in a vector +\item \code{network_dims()}: Returns the dimensions of a network in a vector as long as the number of modes in the network. -\item \code{graph_node_attributes()}: Returns a vector of nodal attributes in a network +\item \code{network_node_attributes()}: Returns a vector of nodal attributes in a network -\item \code{graph_tie_attributes()}: Returns a vector of edge attributes in a network +\item \code{network_tie_attributes()}: Returns a vector of edge attributes in a network }} \examples{ @@ -92,12 +92,12 @@ node_attribute(mpn_elite_mex, "full_name") tie_attribute(ison_algebra, "task_tie") tie_weights(to_mode1(ison_southern_women)) tie_signs(ison_marvel_relationships) -graph_nodes(ison_southern_women) -graph_ties(ison_southern_women) -graph_dims(ison_southern_women) -graph_dims(to_mode1(ison_southern_women)) -graph_node_attributes(mpn_elite_mex) -graph_tie_attributes(mpn_elite_mex) +network_nodes(ison_southern_women) +network_ties(ison_southern_women) +network_dims(ison_southern_women) +network_dims(to_mode1(ison_southern_women)) +network_node_attributes(mpn_elite_mex) +network_tie_attributes(mpn_elite_mex) } \seealso{ Other manipulations: diff --git a/man/ison_networkers.Rd b/man/ison_networkers.Rd index dc6371b8..d1efee93 100644 --- a/man/ison_networkers.Rd +++ b/man/ison_networkers.Rd @@ -42,8 +42,6 @@ on an Electronic Information Exchange System among them. Node attributes include the number of citations (\code{Citations}) and the discipline of the researchers (\code{Discipline}). Edge weights illustrate the number of emails sent from one academic to another over the studied time period. - -\if{latex}{\figure{isonnetworkers.pdf}{options: width=7cm}} } \references{ Freeman, Sue C. and Linton C. Freeman. 1979. diff --git a/man/graph_census.Rd b/man/network_census.Rd similarity index 62% rename from man/graph_census.Rd rename to man/network_census.Rd index 3a9cb8b8..fe0613c5 100644 --- a/man/graph_census.Rd +++ b/man/network_census.Rd @@ -1,20 +1,20 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/motif_census.R -\name{graph_census} -\alias{graph_census} -\alias{graph_dyad_census} -\alias{graph_triad_census} -\alias{graph_mixed_census} +\name{network_census} +\alias{network_census} +\alias{network_dyad_census} +\alias{network_triad_census} +\alias{network_mixed_census} \title{Censuses of graphs' motifs} \source{ Alejandro Espinosa 'netmem' } \usage{ -graph_dyad_census(object) +network_dyad_census(object) -graph_triad_census(object) +network_triad_census(object) -graph_mixed_census(object, object2) +network_mixed_census(object, object2) } \arguments{ \item{object}{A migraph-consistent object.} @@ -26,19 +26,19 @@ Censuses of graphs' motifs } \section{Functions}{ \itemize{ -\item \code{graph_dyad_census()}: Returns a census of dyad motifs in a network +\item \code{network_dyad_census()}: Returns a census of dyad motifs in a network -\item \code{graph_triad_census()}: Returns a census of triad motifs in a network +\item \code{network_triad_census()}: Returns a census of triad motifs in a network -\item \code{graph_mixed_census()}: Returns a census of triad motifs that span +\item \code{network_mixed_census()}: Returns a census of triad motifs that span a one-mode and a two-mode network }} \examples{ -graph_dyad_census(ison_adolescents) -graph_triad_census(ison_adolescents) +network_dyad_census(ison_adolescents) +network_triad_census(ison_adolescents) marvel_friends <- to_unsigned(ison_marvel_relationships, "positive") -(mixed_cen <- graph_mixed_census(marvel_friends, ison_marvel_teams)) +(mixed_cen <- network_mixed_census(marvel_friends, ison_marvel_teams)) } \references{ Davis, James A., and Samuel Leinhardt. 1967. diff --git a/man/node_census.Rd b/man/node_census.Rd index 30973002..8e524fa8 100644 --- a/man/node_census.Rd +++ b/man/node_census.Rd @@ -100,6 +100,6 @@ Opsahl, Tore, Filip Agneessens, and John Skvoretz. 2010. } \seealso{ Other motifs: -\code{\link{graph_census}} +\code{\link{network_census}} } \concept{motifs} diff --git a/man/reexports.Rd b/man/reexports.Rd index 4f385d74..435fd39a 100644 --- a/man/reexports.Rd +++ b/man/reexports.Rd @@ -40,7 +40,7 @@ below to see their documentation. \item{ggplot2}{\code{\link[ggplot2]{aes}}, \code{\link[ggplot2]{ggplot}}, \code{\link[ggplot2]{ggsave}}, \code{\link[ggplot2:labs]{ggtitle}}, \code{\link[ggplot2]{labs}}, \code{\link[ggplot2:labs]{xlab}}, \code{\link[ggplot2:labs]{ylab}}} - \item{igraph}{\code{\link[igraph:is_igraph]{is.igraph}}, \code{\link[igraph:make_bipartite_graph]{is_bipartite}}} + \item{igraph}{\code{\link[igraph:make_bipartite_graph]{is_bipartite}}, \code{\link[igraph:is_igraph]{is.igraph}}} \item{network}{\code{\link[network:network]{as.network}}, \code{\link[network:network]{is.network}}} diff --git a/man/tests.Rd b/man/tests.Rd index 5af859c7..035dab40 100644 --- a/man/tests.Rd +++ b/man/tests.Rd @@ -76,11 +76,11 @@ against a distribution of measures on permutations of the original network marvel_friends <- to_unsigned(ison_marvel_relationships) marvel_friends <- to_giant(marvel_friends) \%>\% to_subgraph(PowerOrigin == "Human") -(cugtest <- test_random(marvel_friends, graph_homophily, attribute = "Attractive", +(cugtest <- test_random(marvel_friends, network_homophily, attribute = "Attractive", times = 200)) plot(cugtest) (qaptest <- test_permutation(marvel_friends, - graph_homophily, attribute = "Attractive", + network_homophily, attribute = "Attractive", times = 200)) plot(qaptest) } diff --git a/tests/testthat/test-make_create.R b/tests/testthat/test-make_create.R index 268facd8..fea80069 100644 --- a/tests/testthat/test-make_create.R +++ b/tests/testthat/test-make_create.R @@ -41,7 +41,7 @@ test_that("star creation works", { test_that("core-periphery creation works", { expect_false(is_twomode(create_core(6))) expect_true(is_twomode(create_core(c(6,6)))) - expect_equal(graph_nodes(create_core(c(10,4))), 14) + expect_equal(network_nodes(create_core(c(10,4))), 14) }) # test_that("nest creation works", { diff --git a/tests/testthat/test-manip_as.R b/tests/testthat/test-manip_as.R index a3961da1..859700fb 100644 --- a/tests/testthat/test-manip_as.R +++ b/tests/testthat/test-manip_as.R @@ -37,7 +37,7 @@ test_that("as_igraph converts correctly",{ expect_s3_class(as_igraph(as_network(ison_southern_women)), "igraph") expect_s3_class(as_igraph(mpn_elite_usa_money), "igraph") expect_error(as_igraph(data3, weight = T)) - expect_equal(graph_nodes(as_igraph(as_network(data2))), graph_nodes(as_igraph(data2))) + expect_equal(network_nodes(as_igraph(as_network(data2))), network_nodes(as_igraph(data2))) # NB: ordering of edges is a little different when converting from network # to igraph. Should not matter though. }) @@ -56,7 +56,7 @@ test_that("as_network converts correctly",{ expect_s3_class(as_network(mpn_elite_usa_money), "network") expect_equal(as_network(as_network(data2)), as_network(data2)) expect_equal(as_network(as_igraph(ison_marvel_relationships)), as_network(ison_marvel_relationships)) - expect_equal(graph_nodes(as_network(dplyr::as_tibble(data2))), graph_nodes(as_network(data2))) + expect_equal(network_nodes(as_network(dplyr::as_tibble(data2))), network_nodes(as_network(data2))) expect_equal(is_directed(ison_southern_women), is_directed(as_network(ison_southern_women))) expect_equal(is_directed(mpn_DemSxP), is_directed(as_network(mpn_DemSxP))) expect_equal(is_directed(ison_adolescents), is_directed(as_network(ison_adolescents))) @@ -77,6 +77,6 @@ test_that("as_edgelist converts correctly", { # test conversion of siena objects test_that("as_tidygraph.siena converts correctly", { - expect_equal(graph_nodes(as_igraph(sienadata)), graph_nodes(as_matrix(sienadata))) - expect_equal(graph_nodes(as_igraph(sienadata)), length(sienadata[["nodeSets"]][["Actors"]])) + expect_equal(network_nodes(as_igraph(sienadata)), network_nodes(as_matrix(sienadata))) + expect_equal(network_nodes(as_igraph(sienadata)), length(sienadata[["nodeSets"]][["Actors"]])) }) diff --git a/tests/testthat/test-manip_grab.R b/tests/testthat/test-manip_grab.R index 2f13d209..eee067aa 100644 --- a/tests/testthat/test-manip_grab.R +++ b/tests/testthat/test-manip_grab.R @@ -38,25 +38,25 @@ test_that("tie_weights works", { expect_equal(tie_weights(net2), tie_attribute(net2, "weight")) }) -test_that("graph_nodes works", { - expect_equal(graph_nodes(net), 5) +test_that("network_nodes works", { + expect_equal(network_nodes(net), 5) }) -test_that("graph_ties works", { - expect_equal(graph_ties(net), 5) +test_that("network_ties works", { + expect_equal(network_ties(net), 5) }) -test_that("graph_dims works", { - expect_equal(graph_dims(ison_karateka), 34) - expect_equal(graph_dims(ison_southern_women), c(18,14)) +test_that("network_dims works", { + expect_equal(network_dims(ison_karateka), 34) + expect_equal(network_dims(ison_southern_women), c(18,14)) }) -test_that("graph_node_attributes works", { - expect_equal(graph_node_attributes(net), c("name", "gender")) - expect_length(graph_node_attributes(net), 2) +test_that("network_node_attributes works", { + expect_equal(network_node_attributes(net), c("name", "gender")) + expect_length(network_node_attributes(net), 2) }) -test_that("graph_tie_attributes works", { - expect_equal(graph_tie_attributes(net2), "weight") - expect_length(graph_tie_attributes(net2), 1) +test_that("network_tie_attributes works", { + expect_equal(network_tie_attributes(net2), "weight") + expect_length(network_tie_attributes(net2), 1) }) diff --git a/tests/testthat/test-manip_to.R b/tests/testthat/test-manip_to.R index c04843ee..ec967e8d 100644 --- a/tests/testthat/test-manip_to.R +++ b/tests/testthat/test-manip_to.R @@ -27,8 +27,8 @@ test_that("to_onemode works",{ }) test_that("to_giant works",{ - expect_equal(graph_nodes(ison_marvel_relationships), 53) - expect_equal(graph_nodes(to_giant(ison_marvel_relationships)), 50) + expect_equal(network_nodes(ison_marvel_relationships), 53) + expect_equal(network_nodes(to_giant(ison_marvel_relationships)), 50) }) test_that("to_uniplex works", { @@ -51,7 +51,7 @@ test_that("to_unsigned works", { test_that("to_named works", { expect_false(is_labelled(ison_brandes)) expect_true(is_labelled(to_named(ison_brandes))) - expect_true(is_labelled(to_named(ison_brandes, seq_len(graph_nodes(ison_brandes))))) + expect_true(is_labelled(to_named(ison_brandes, seq_len(network_nodes(ison_brandes))))) }) test_that("multilevel works", { @@ -64,7 +64,7 @@ test_that("matrix projected correctly by rows",{ expect_true(all(node_names(to_mode1(ison_southern_women)) %in% node_names(ison_southern_women))) expect_true(length(node_names(to_mode1(ison_southern_women))) != length(node_names(ison_southern_women))) expect_equal(length(node_names(to_mode1(ison_southern_women))), length(rownames(as_matrix(ison_southern_women)))) - expect_equal(graph_nodes(to_mode1(ison_southern_women, "count")), graph_nodes(to_mode1(ison_southern_women, "jaccard"))) + expect_equal(network_nodes(to_mode1(ison_southern_women, "count")), network_nodes(to_mode1(ison_southern_women, "jaccard"))) expect_true(is_weighted(to_mode1(mpn_elite_usa_advice, "pearson"))) expect_false(tie_weights(to_mode1(mpn_elite_usa_advice, "rand"))[3] == tie_weights(to_mode1(mpn_elite_usa_advice, "count"))[3]) }) @@ -74,7 +74,7 @@ test_that("matrix projected correctly by columns",{ expect_true(all(node_names(to_mode2(ison_southern_women)) %in% node_names(ison_southern_women))) expect_true(length(node_names(to_mode2(ison_southern_women))) != length(node_names(ison_southern_women))) expect_equal(length(node_names(to_mode2(ison_southern_women))), length(colnames(as_matrix(ison_southern_women)))) - expect_equal(graph_nodes(to_mode2(ison_southern_women, "count")), graph_nodes(to_mode2(ison_southern_women, "jaccard"))) + expect_equal(network_nodes(to_mode2(ison_southern_women, "count")), network_nodes(to_mode2(ison_southern_women, "jaccard"))) expect_true(is_weighted(to_mode2(mpn_elite_usa_advice, "pearson"))) expect_false(tie_weights(to_mode2(mpn_elite_usa_advice, "rand"))[1] == tie_weights(to_mode2(mpn_elite_usa_advice, "count"))[1]) }) @@ -92,6 +92,6 @@ test_that("to_blocks works", { test_that("to matching works", { sw <- as_edgelist(to_matching(ison_southern_women)) - expect_equal(graph_nodes(to_matching(ison_southern_women)), graph_nodes(ison_southern_women)) + expect_equal(network_nodes(to_matching(ison_southern_women)), network_nodes(ison_southern_women)) expect_true(nrow(sw) == nrow(dplyr::distinct(sw))) }) diff --git a/tests/testthat/test-mark_nodes.R b/tests/testthat/test-mark_nodes.R index a0b82958..c2e3e3ea 100644 --- a/tests/testthat/test-mark_nodes.R +++ b/tests/testthat/test-mark_nodes.R @@ -2,22 +2,22 @@ test_that("node cuts works", { expect_s3_class(node_is_cutpoint(ison_algebra), "node_mark") expect_length(node_is_cutpoint(ison_southern_women), - graph_nodes(ison_southern_women)) + network_nodes(ison_southern_women)) }) test_that("node isolate works", { expect_s3_class(node_is_isolate(ison_brandes), "logical") - expect_equal(length(node_is_isolate(ison_brandes)), graph_nodes(ison_brandes)) + expect_equal(length(node_is_isolate(ison_brandes)), network_nodes(ison_brandes)) }) test_that("node_is_max works", { - expect_equal(length(node_is_max(node_betweenness(ison_brandes))), graph_nodes(ison_brandes)) + expect_equal(length(node_is_max(node_betweenness(ison_brandes))), network_nodes(ison_brandes)) expect_equal(sum(node_is_max(node_betweenness(ison_brandes)) == TRUE), 1) expect_s3_class(node_is_max(node_betweenness(ison_brandes)), "logical") }) test_that("node_is_min works", { - expect_equal(length(node_is_min(node_betweenness(ison_brandes))), graph_nodes(ison_brandes)) + expect_equal(length(node_is_min(node_betweenness(ison_brandes))), network_nodes(ison_brandes)) expect_equal(sum(node_is_min(node_betweenness(ison_brandes)) == TRUE), 4) expect_s3_class(node_is_min(node_betweenness(ison_brandes)), "logical") }) diff --git a/tests/testthat/test-mark_ties.R b/tests/testthat/test-mark_ties.R index 2933eddd..54e0266d 100644 --- a/tests/testthat/test-mark_ties.R +++ b/tests/testthat/test-mark_ties.R @@ -16,17 +16,17 @@ test_that("tie_is_loop works", { }) test_that("tie_is_bridge works", { - expect_equal(length(tie_is_bridge(graph1)), graph_ties(graph1)) + expect_equal(length(tie_is_bridge(graph1)), network_ties(graph1)) }) test_that("tie_is_max works", { - expect_equal(length(tie_is_max(tie_betweenness(ison_brandes))), graph_ties(ison_brandes)) + expect_equal(length(tie_is_max(tie_betweenness(ison_brandes))), network_ties(ison_brandes)) expect_equal(sum(tie_is_max(tie_betweenness(ison_brandes)) == TRUE), 1) expect_s3_class(tie_is_max(tie_betweenness(ison_brandes)), "logical") }) test_that("tie_is_min works", { - expect_equal(length(tie_is_min(tie_betweenness(ison_brandes))), graph_ties(ison_brandes)) + expect_equal(length(tie_is_min(tie_betweenness(ison_brandes))), network_ties(ison_brandes)) expect_equal(sum(tie_is_min(tie_betweenness(ison_brandes)) == TRUE), 1) expect_s3_class(tie_is_min(tie_betweenness(ison_brandes)), "logical") }) diff --git a/tests/testthat/test-measure_centrality.R b/tests/testthat/test-measure_centrality.R index 7f013898..29ed5d47 100644 --- a/tests/testthat/test-measure_centrality.R +++ b/tests/testthat/test-measure_centrality.R @@ -94,34 +94,34 @@ test_that("node measure class works", { ####### Centralization test_that("one-mode centralisation is calculated correctly", { - expect_equal(as.numeric(graph_degree(mpn_elite_mex)), 0.303, tolerance = 0.001) - expect_equal(as.numeric(graph_closeness(mpn_elite_mex)), 0.386, tolerance = 0.001) - expect_equal(as.numeric(graph_betweenness(mpn_elite_mex)), 0.202, tolerance = 0.001) - expect_equal(as.numeric(graph_eigenvector(mpn_elite_mex)), 0.630, tolerance = 0.001) + expect_equal(as.numeric(network_degree(mpn_elite_mex)), 0.303, tolerance = 0.001) + expect_equal(as.numeric(network_closeness(mpn_elite_mex)), 0.386, tolerance = 0.001) + expect_equal(as.numeric(network_betweenness(mpn_elite_mex)), 0.202, tolerance = 0.001) + expect_equal(as.numeric(network_eigenvector(mpn_elite_mex)), 0.630, tolerance = 0.001) }) test_that("two mode degree centralisation calculated correctly", { - expect_equal(as.numeric(graph_degree(ison_southern_women, normalized = FALSE)), c(0.1813, 0.5097), tolerance = 0.001) - expect_equal(as.numeric(graph_degree(ison_southern_women, direction = "in")), c(0.2308, 0.4661), tolerance = 0.001) - expect_equal(as.numeric(graph_degree(ison_southern_women, normalized = TRUE)), c(0.2268, 0.4744), tolerance = 0.001) + expect_equal(as.numeric(network_degree(ison_southern_women, normalized = FALSE)), c(0.1813, 0.5097), tolerance = 0.001) + expect_equal(as.numeric(network_degree(ison_southern_women, direction = "in")), c(0.2308, 0.4661), tolerance = 0.001) + expect_equal(as.numeric(network_degree(ison_southern_women, normalized = TRUE)), c(0.2268, 0.4744), tolerance = 0.001) }) test_that("two mode closeness centralisation calculated correctly", { - expect_equal(as.numeric(graph_closeness(ison_southern_women, normalized = TRUE)), c(0.2843, 0.4418), tolerance = 0.001) - expect_equal(as.numeric(graph_closeness(ison_southern_women, direction = "in")), c(0.2135, 0.5285), tolerance = 0.001) + expect_equal(as.numeric(network_closeness(ison_southern_women, normalized = TRUE)), c(0.2843, 0.4418), tolerance = 0.001) + expect_equal(as.numeric(network_closeness(ison_southern_women, direction = "in")), c(0.2135, 0.5285), tolerance = 0.001) }) test_that("two mode betweenness centralisation calculated correctly", { - expect_equal(as.numeric(graph_betweenness(ison_southern_women, normalized = FALSE)), c(0.0580, 0.2073), tolerance = 0.001) - expect_equal(as.numeric(graph_betweenness(ison_southern_women, direction = "in")), c(0.0668, 0.1982), tolerance = 0.001) - expect_equal(as.numeric(graph_betweenness(ison_southern_women, normalized = TRUE)), c(0.0586, 0.207), tolerance = 0.001) + expect_equal(as.numeric(network_betweenness(ison_southern_women, normalized = FALSE)), c(0.0580, 0.2073), tolerance = 0.001) + expect_equal(as.numeric(network_betweenness(ison_southern_women, direction = "in")), c(0.0668, 0.1982), tolerance = 0.001) + expect_equal(as.numeric(network_betweenness(ison_southern_women, normalized = TRUE)), c(0.0586, 0.207), tolerance = 0.001) }) -test_that("graph_measure class works", { - expect_s3_class(graph_degree(ison_algebra), "graph_measure") - expect_s3_class(graph_betweenness(mpn_elite_usa_advice), "graph_measure") - expect_s3_class(graph_closeness(mpn_elite_usa_advice), "graph_measure") - expect_output(print(graph_degree(ison_algebra))) +test_that("network_measure class works", { + expect_s3_class(network_degree(ison_algebra), "network_measure") + expect_s3_class(network_betweenness(mpn_elite_usa_advice), "network_measure") + expect_s3_class(network_closeness(mpn_elite_usa_advice), "network_measure") + expect_output(print(network_degree(ison_algebra))) }) ####### Edge centrality @@ -129,14 +129,14 @@ test_that("tie_degree works", { expect_s3_class(tie_degree(ison_adolescents), "tie_measure") expect_length(tie_degree(ison_adolescents), - graph_ties(ison_adolescents)) + network_ties(ison_adolescents)) }) test_that("tie_betweenness works", { expect_s3_class(tie_betweenness(ison_adolescents), "tie_measure") expect_length(tie_betweenness(ison_adolescents), - graph_ties(ison_adolescents)) + network_ties(ison_adolescents)) expect_equal(unname(tie_betweenness(ison_adolescents)[1:3]), c(7,3,5), tolerance = 0.001) }) @@ -145,7 +145,7 @@ test_that("tie_closeness works", { expect_s3_class(tie_closeness(ison_adolescents), "tie_measure") expect_length(tie_closeness(ison_adolescents), - graph_ties(ison_adolescents)) + network_ties(ison_adolescents)) expect_equal(unname(tie_closeness(ison_adolescents)[1:3]), c(0.562,0.692,0.600), tolerance = 0.001) }) @@ -154,5 +154,5 @@ test_that("tie_eigenvector works", { expect_s3_class(tie_eigenvector(ison_southern_women), "tie_measure") expect_length(tie_eigenvector(ison_southern_women), - graph_ties(ison_southern_women)) + network_ties(ison_southern_women)) }) diff --git a/tests/testthat/test-measure_closure.R b/tests/testthat/test-measure_closure.R index 141e7496..310a68dd 100644 --- a/tests/testthat/test-measure_closure.R +++ b/tests/testthat/test-measure_closure.R @@ -1,40 +1,40 @@ -test_that("graph density works", { - expect_s3_class(graph_density(ison_southern_women), "graph_measure") - expect_equal(as.numeric(graph_density(create_empty(10))), 0) - expect_equal(as.numeric(graph_density(create_empty(c(10,6)))), 0) - expect_equal(as.numeric(graph_density(create_complete(10))), 1) - expect_equal(as.numeric(graph_density(create_complete(c(10,6)))), 1) - expect_output(print(graph_density(create_complete(10)))) +test_that("network density works", { + expect_s3_class(network_density(ison_southern_women), "network_measure") + expect_equal(as.numeric(network_density(create_empty(10))), 0) + expect_equal(as.numeric(network_density(create_empty(c(10,6)))), 0) + expect_equal(as.numeric(network_density(create_complete(10))), 1) + expect_equal(as.numeric(network_density(create_complete(c(10,6)))), 1) + expect_output(print(network_density(create_complete(10)))) }) -test_that("graph reciprocity works", { - expect_s3_class(graph_reciprocity(ison_networkers), "graph_measure") - expect_output(print(graph_reciprocity(ison_networkers))) - expect_length(graph_reciprocity(ison_networkers), 1) - expect_equal(as.numeric(graph_reciprocity(ison_networkers)), +test_that("network reciprocity works", { + expect_s3_class(network_reciprocity(ison_networkers), "network_measure") + expect_output(print(network_reciprocity(ison_networkers))) + expect_length(network_reciprocity(ison_networkers), 1) + expect_equal(as.numeric(network_reciprocity(ison_networkers)), igraph::reciprocity(as_igraph(ison_networkers))) }) test_that("one-mode object clustering is reported correctly",{ - expect_equal(as.numeric(graph_transitivity(ison_algebra)), + expect_equal(as.numeric(network_transitivity(ison_algebra)), 0.69787, tolerance = 0.001) - expect_s3_class(graph_transitivity(ison_algebra), "graph_measure") - expect_output(print(graph_transitivity(ison_algebra))) + expect_s3_class(network_transitivity(ison_algebra), "network_measure") + expect_output(print(network_transitivity(ison_algebra))) }) test_that("two-mode object clustering is reported correctly",{ - expect_equal(as.numeric(graph_equivalency(ison_southern_women)), + expect_equal(as.numeric(network_equivalency(ison_southern_women)), 0.4872, tolerance = 0.001) - expect_s3_class(graph_equivalency(ison_southern_women), "graph_measure") - expect_output(print(graph_equivalency(ison_southern_women))) + expect_s3_class(network_equivalency(ison_southern_women), "network_measure") + expect_output(print(network_equivalency(ison_southern_women))) }) test_that("three-mode clustering calculated correctly",{ mat1 <- create_ring(5,10) mat2 <- create_ring(5,8) - expect_equal(as.numeric(graph_congruency(mat1, mat2)), + expect_equal(as.numeric(network_congruency(mat1, mat2)), 0.7143, tolerance = 0.001) - expect_s3_class(graph_congruency(mat1, mat2), "graph_measure") - expect_output(print(graph_congruency(mat1, mat2))) + expect_s3_class(network_congruency(mat1, mat2), "network_measure") + expect_output(print(network_congruency(mat1, mat2))) }) diff --git a/tests/testthat/test-measure_cohesion.R b/tests/testthat/test-measure_cohesion.R index d874e041..f6ef95f2 100644 --- a/tests/testthat/test-measure_cohesion.R +++ b/tests/testthat/test-measure_cohesion.R @@ -1,25 +1,25 @@ test_that("graph components works", { - expect_s3_class(graph_components(mpn_bristol), "graph_measure") - expect_equal(as.numeric(graph_components(mpn_bristol)), 3) + expect_s3_class(network_components(mpn_bristol), "network_measure") + expect_equal(as.numeric(network_components(mpn_bristol)), 3) }) test_that("graph cohesion works", { - expect_s3_class(graph_cohesion(mpn_bristol), "graph_measure") - expect_equal(as.numeric(graph_cohesion(mpn_bristol)), 0) + expect_s3_class(network_cohesion(mpn_bristol), "network_measure") + expect_equal(as.numeric(network_cohesion(mpn_bristol)), 0) }) test_that("graph adhesion works", { - expect_s3_class(graph_adhesion(mpn_bristol), "graph_measure") - expect_equal(as.numeric(graph_adhesion(mpn_bristol)), 0) + expect_s3_class(network_adhesion(mpn_bristol), "network_measure") + expect_equal(as.numeric(network_adhesion(mpn_bristol)), 0) }) test_that("graph diameter works", { - expect_s3_class(graph_diameter(mpn_bristol), "graph_measure") - expect_equal(as.numeric(graph_diameter(mpn_bristol)), 6) + expect_s3_class(network_diameter(mpn_bristol), "network_measure") + expect_equal(as.numeric(network_diameter(mpn_bristol)), 6) }) test_that("graph length works", { - expect_s3_class(graph_length(mpn_bristol), "graph_measure") - expect_equal(as.numeric(graph_length(mpn_bristol)), 2.451265, + expect_s3_class(network_length(mpn_bristol), "network_measure") + expect_equal(as.numeric(network_length(mpn_bristol)), 2.451265, tolerance = 0.000001) }) diff --git a/tests/testthat/test-measure_diversity.R b/tests/testthat/test-measure_diversity.R index 711d199f..3b046fce 100644 --- a/tests/testthat/test-measure_diversity.R +++ b/tests/testthat/test-measure_diversity.R @@ -1,16 +1,16 @@ #*************** Test the diversity family of functions ***********************# test_that("Blau index function works", { - expect_equal(as.numeric(graph_diversity(ison_marvel_relationships, "Gender")), 0.306, tolerance = 0.001) - expect_equal(as.numeric(graph_diversity(ison_marvel_relationships, "Gender", "Rich")), + expect_equal(as.numeric(network_diversity(ison_marvel_relationships, "Gender")), 0.306, tolerance = 0.001) + expect_equal(as.numeric(network_diversity(ison_marvel_relationships, "Gender", "Rich")), c(0.337,0.165), tolerance = 0.001) }) test_that("EI index function works", { - expect_equal(as.numeric(graph_homophily(mpn_elite_mex, "military")), -0.3675, tolerance = 0.001) + expect_equal(as.numeric(network_homophily(mpn_elite_mex, "military")), -0.3675, tolerance = 0.001) }) -test_that("graph_assortativity function works", { - expect_length(graph_assortativity(mpn_elite_mex), 1) - expect_s3_class(graph_assortativity(mpn_elite_mex), "graph_measure") +test_that("network_assortativity function works", { + expect_length(network_assortativity(mpn_elite_mex), 1) + expect_s3_class(network_assortativity(mpn_elite_mex), "network_measure") }) diff --git a/tests/testthat/test-measure_features.R b/tests/testthat/test-measure_features.R index 4f7b9467..ba686cf4 100644 --- a/tests/testthat/test-measure_features.R +++ b/tests/testthat/test-measure_features.R @@ -1,32 +1,32 @@ set.seed(123) test_that("small-world metrics for two mode networks are calculated and displayed correctly", { - expect_s3_class(graph_smallworld(ison_southern_women), "graph_measure") - expect_equal(as.numeric(graph_smallworld(ison_southern_women)), 1.323, tolerance = 0.02) + expect_s3_class(network_smallworld(ison_southern_women), "network_measure") + expect_equal(as.numeric(network_smallworld(ison_southern_women)), 1.323, tolerance = 0.02) }) -test_that("graph balance works", { - expect_s3_class(graph_balance(ison_marvel_relationships), "graph_measure") - expect_equal(as.numeric(graph_balance(ison_marvel_relationships)), 0.668, tolerance = 0.01) - expect_length(graph_balance(ison_marvel_relationships), 1) - expect_error(graph_balance(ison_adolescents)) +test_that("network_balance works", { + expect_s3_class(network_balance(ison_marvel_relationships), "network_measure") + expect_equal(as.numeric(network_balance(ison_marvel_relationships)), 0.668, tolerance = 0.01) + expect_length(network_balance(ison_marvel_relationships), 1) + expect_error(network_balance(ison_adolescents)) }) -test_that("graph modularity works for two mode networks", { - expect_s3_class(graph_modularity(ison_southern_women, - node_kernighanlin(ison_southern_women)), "graph_measure") - expect_length(graph_modularity(ison_southern_women, +test_that("network_modularity works for two mode networks", { + expect_s3_class(network_modularity(ison_southern_women, + node_kernighanlin(ison_southern_women)), "network_measure") + expect_length(network_modularity(ison_southern_women, node_kernighanlin(ison_southern_women)), 1) }) -test_that("graph_core works", { - expect_s3_class(graph_core(ison_adolescents), "graph_measure") - expect_equal(length(graph_core(ison_adolescents)), - length(graph_core(ison_southern_women))) +test_that("network_core works", { + expect_s3_class(network_core(ison_adolescents), "network_measure") + expect_equal(length(network_core(ison_adolescents)), + length(network_core(ison_southern_women))) }) -test_that("graph_factions works", { - expect_s3_class(graph_factions(ison_adolescents), "graph_measure") - expect_equal(length(graph_factions(ison_adolescents)), - length(graph_factions(ison_southern_women))) +test_that("network_factions works", { + expect_s3_class(network_factions(ison_adolescents), "network_measure") + expect_equal(length(network_factions(ison_adolescents)), + length(network_factions(ison_southern_women))) }) diff --git a/tests/testthat/test-measure_holes.R b/tests/testthat/test-measure_holes.R index 1c3b6496..235d404d 100644 --- a/tests/testthat/test-measure_holes.R +++ b/tests/testthat/test-measure_holes.R @@ -1,18 +1,18 @@ test_that("redundancy is reported correctly", { expect_s3_class(node_redundancy(ison_brandes), "node_measure") expect_s3_class(node_redundancy(mpn_elite_usa_advice), "node_measure") - expect_equal(length(node_redundancy(ison_brandes)), graph_nodes(ison_brandes)) + expect_equal(length(node_redundancy(ison_brandes)), network_nodes(ison_brandes)) expect_equal(length(node_redundancy(mpn_elite_usa_advice)), - graph_nodes(mpn_elite_usa_advice)) + network_nodes(mpn_elite_usa_advice)) expect_named(node_redundancy(mpn_elite_usa_advice)) }) test_that("effective size is calculated and reported correctly", { expect_s3_class(node_effsize(ison_brandes), "node_measure") expect_s3_class(node_effsize(mpn_elite_usa_advice), "node_measure") - expect_equal(length(node_effsize(ison_brandes)), graph_nodes(ison_brandes)) + expect_equal(length(node_effsize(ison_brandes)), network_nodes(ison_brandes)) expect_equal(length(node_effsize(mpn_elite_usa_advice)), - graph_nodes(mpn_elite_usa_advice)) + network_nodes(mpn_elite_usa_advice)) expect_named(node_effsize(mpn_elite_usa_advice)) x <- node_degree(ison_southern_women, normalized = FALSE)[1] - node_redundancy(ison_southern_women)[1] expect_equal(node_effsize(ison_southern_women)[1], x) @@ -21,9 +21,9 @@ test_that("effective size is calculated and reported correctly", { test_that("efficiency is reported correctly", { expect_s3_class(node_efficiency(ison_brandes), "node_measure") expect_s3_class(node_efficiency(mpn_elite_usa_advice), "node_measure") - expect_equal(length(node_efficiency(ison_brandes)), graph_nodes(ison_brandes)) + expect_equal(length(node_efficiency(ison_brandes)), network_nodes(ison_brandes)) expect_equal(length(node_efficiency(mpn_elite_usa_advice)), - graph_nodes(mpn_elite_usa_advice)) + network_nodes(mpn_elite_usa_advice)) }) test_that("constraint scores are reported correctly for two-mode notworks",{ @@ -40,8 +40,8 @@ test_that("constraint scores are reported correctly for one-mode notworks",{ test_that("hierarchy is reported correctly", { expect_s3_class(node_hierarchy(ison_brandes), "node_measure") expect_s3_class(node_hierarchy(mpn_elite_usa_advice), "node_measure") - expect_equal(length(node_hierarchy(ison_brandes)), graph_nodes(ison_brandes)) + expect_equal(length(node_hierarchy(ison_brandes)), network_nodes(ison_brandes)) expect_equal(length(node_hierarchy(mpn_elite_usa_advice)), - graph_nodes(mpn_elite_usa_advice)) + network_nodes(mpn_elite_usa_advice)) expect_named(node_hierarchy(mpn_elite_usa_advice)) }) diff --git a/tests/testthat/test-member_community.R b/tests/testthat/test-member_community.R index 9e025b4c..3e65c25d 100644 --- a/tests/testthat/test-member_community.R +++ b/tests/testthat/test-member_community.R @@ -1,6 +1,6 @@ test_that("node_kernighanlin algorithm works", { expect_s3_class(node_kernighanlin(mpn_elite_mex), "node_member") expect_length(node_kernighanlin(mpn_elite_mex), - graph_nodes(mpn_elite_mex)) + network_nodes(mpn_elite_mex)) expect_false(any(node_kernighanlin(mpn_elite_mex) > 2)) }) diff --git a/tests/testthat/test-member_equivalence.R b/tests/testthat/test-member_equivalence.R index 4ee48661..0d90a9dd 100644 --- a/tests/testthat/test-member_equivalence.R +++ b/tests/testthat/test-member_equivalence.R @@ -30,14 +30,14 @@ test_that("equivalence clustering works", { expect_equal(c, node_structural_equivalence(ison_adolescents)) expect_equal(r, node_regular_equivalence(mpn_elite_mex, "silhouette", "hier")) expect_equal(y, node_automorphic_equivalence(mpn_elite_usa_advice, "silhouette", "hier")) - expect_equal(graph_nodes(ison_adolescents), length(f)) - expect_equal(graph_nodes(ison_adolescents), length(d)) - expect_equal(graph_nodes(ison_adolescents), length(g)) - expect_equal(graph_nodes(mpn_elite_mex), length(v)) - expect_equal(graph_nodes(mpn_elite_mex), length(s)) - expect_equal(graph_nodes(mpn_elite_mex), length(t)) - expect_equal(graph_nodes(mpn_elite_usa_advice), length(w)) - expect_equal(graph_nodes(mpn_elite_usa_advice), length(z)) + expect_equal(network_nodes(ison_adolescents), length(f)) + expect_equal(network_nodes(ison_adolescents), length(d)) + expect_equal(network_nodes(ison_adolescents), length(g)) + expect_equal(network_nodes(mpn_elite_mex), length(v)) + expect_equal(network_nodes(mpn_elite_mex), length(s)) + expect_equal(network_nodes(mpn_elite_mex), length(t)) + expect_equal(network_nodes(mpn_elite_usa_advice), length(w)) + expect_equal(network_nodes(mpn_elite_usa_advice), length(z)) expect_false(names(x[1]) %in% names(x[2:length(x)])) expect_false(names(y[1]) %in% names(y[2:length(y)])) expect_true(3 %in% h) diff --git a/tests/testthat/test-model_tests.R b/tests/testthat/test-model_tests.R index 76ccb772..12c10621 100644 --- a/tests/testthat/test-model_tests.R +++ b/tests/testthat/test-model_tests.R @@ -2,11 +2,11 @@ marvel_friends <- to_giant(to_unsigned(ison_marvel_relationships)) %>% to_subgraph(PowerOrigin == "Human") cugtest <- test_random(marvel_friends, - graph_homophily, + network_homophily, attribute = "Attractive", times = 200) cugtest2 <- test_random(marvel_friends, - graph_betweenness, + network_betweenness, times = 200) test_that("test_random works", { @@ -20,7 +20,7 @@ test_that("test_random works", { expect_equal(class(cugtest$plteobs), "numeric") expect_equal(class(cugtest$pgteobs), "numeric") expect_equal(cugtest$reps, 200) - expect_s3_class(cugtest, "graph_test") + expect_s3_class(cugtest, "network_test") # Test stuff cug2 expect_equal(as.numeric(cugtest2$testval), 0.238, tolerance = 0.001) expect_equal(length(cugtest2$testdist), 200) # NB: Stochastic @@ -30,7 +30,7 @@ test_that("test_random works", { expect_equal(round(cugtest2$plteobs), 1) expect_equal(round(cugtest2$pgteobs), 0) expect_equal(cugtest2$reps, 200) - expect_s3_class(cugtest2, "graph_test") + expect_s3_class(cugtest2, "network_test") }) # Set the qaptest up @@ -38,7 +38,7 @@ marvel_friends <- to_unsigned(ison_marvel_relationships) marvel_friends <- to_giant(marvel_friends) marvel_friends <- to_subgraph(marvel_friends, PowerOrigin == "Human") qaptest <- test_permutation(marvel_friends, - graph_homophily, + network_homophily, attribute = "Attractive", times = 200) test_that("test_permutation works", { @@ -47,7 +47,7 @@ test_that("test_permutation works", { expect_equal(class(qaptest$plteobs), "numeric") # NB: Stochastic expect_equal(class(qaptest$pgteobs), "numeric") # NB: Stochastic expect_equal(qaptest$reps, 200) - expect_s3_class(qaptest, "graph_test") + expect_s3_class(qaptest, "network_test") }) cugplot <- plot(cugtest) diff --git a/tests/testthat/test-motif_census.R b/tests/testthat/test-motif_census.R index 5a9e55ad..857d2291 100644 --- a/tests/testthat/test-motif_census.R +++ b/tests/testthat/test-motif_census.R @@ -15,24 +15,24 @@ test_that("node triad census works", { expect_equal(colnames(test)[1:3], c("003", "012", "102")) }) -test <- graph_dyad_census(ison_adolescents) -test_that("graph dyad census works", { +test <- network_dyad_census(ison_adolescents) +test_that("network_dyad census works", { expect_equal(test[[1]], 10) expect_equal(test[[2]], 18) expect_equal(names(test), c("Mutual", "Null")) - expect_s3_class(test, "graph_motif") + expect_s3_class(test, "network_motif") # Error - expect_error(graph_dyad_census(ison_southern_women)) + expect_error(network_dyad_census(ison_southern_women)) }) -test <- graph_triad_census(ison_adolescents) -test_that("graph triad census works", { +test <- network_triad_census(ison_adolescents) +test_that("network_triad census works", { expect_equal(test[[1]], 13) expect_equal(test[[3]], 29) expect_equal(names(test), c("003", "012", "102", "201", "210", "300")) - expect_s3_class(test, "graph_motif") + expect_s3_class(test, "network_motif") # Error - expect_error(graph_triad_census(ison_southern_women)) + expect_error(network_triad_census(ison_southern_women)) }) test <- node_quad_census(ison_southern_women) @@ -41,21 +41,21 @@ test_that("node quad census works", { expect_equal(test[1,1], 1402) }) -test_that("graph mixed census works", { +test_that("network_mixed census works", { marvel_friends <- to_unsigned(ison_marvel_relationships, "positive") - test <- graph_mixed_census(marvel_friends, ison_marvel_teams) - expect_s3_class(test, "graph_motif") + test <- network_mixed_census(marvel_friends, ison_marvel_teams) + expect_s3_class(test, "network_motif") expect_equal(unname(test[1]), 1137) expect_equal(names(test[1]), "22") # Errors - expect_error(graph_mixed_census(ison_southern_women, ison_marvel_teams)) - expect_error(graph_mixed_census(ison_marvel_teams, ison_southern_women)) - expect_error(graph_mixed_census(ison_karateka, ison_marvel_teams)) + expect_error(network_mixed_census(ison_southern_women, ison_marvel_teams)) + expect_error(network_mixed_census(ison_marvel_teams, ison_southern_women)) + expect_error(network_mixed_census(ison_karateka, ison_marvel_teams)) }) test <- node_path_census(ison_southern_women) test_that("node path census works", { - expect_equal(graph_nodes(ison_adolescents), + expect_equal(network_nodes(ison_adolescents), nrow(node_path_census(ison_adolescents))) expect_s3_class(test, "node_motif") expect_true(nrow(node_path_census(ison_southern_women)) == ncol(node_path_census(ison_southern_women))) diff --git a/vignettes/p1data.Rmd b/vignettes/p1data.Rmd index a671e6a4..3827c26c 100644 --- a/vignettes/p1data.Rmd +++ b/vignettes/p1data.Rmd @@ -122,14 +122,14 @@ ison_southern_women # this is in igraph format #> IGRAPH f8d9f5f UN-B 32 93 -- #> + attr: type (v/l), name (v/c) #> + edges from f8d9f5f (vertex names): -#> [1] EVELYN --E1 EVELYN --E2 EVELYN --E3 -#> [4] EVELYN --E4 EVELYN --E5 EVELYN --E6 -#> [7] EVELYN --E8 EVELYN --E9 LAURA --E1 -#> [10] LAURA --E2 LAURA --E3 LAURA --E5 -#> [13] LAURA --E6 LAURA --E7 LAURA --E8 -#> [16] THERESA--E2 THERESA--E3 THERESA--E4 -#> [19] THERESA--E5 THERESA--E6 THERESA--E7 -#> [22] THERESA--E8 THERESA--E9 BRENDA --E1 +#> [1] EVELYN --E1 EVELYN --E2 EVELYN --E3 EVELYN --E4 +#> [5] EVELYN --E5 EVELYN --E6 EVELYN --E8 EVELYN --E9 +#> [9] LAURA --E1 LAURA --E2 LAURA --E3 LAURA --E5 +#> [13] LAURA --E6 LAURA --E7 LAURA --E8 THERESA--E2 +#> [17] THERESA--E3 THERESA--E4 THERESA--E5 THERESA--E6 +#> [21] THERESA--E7 THERESA--E8 THERESA--E9 BRENDA --E1 +#> [25] BRENDA --E3 BRENDA --E4 BRENDA --E5 BRENDA --E6 +#> [29] BRENDA --E7 BRENDA --E8 #> + ... omitted several edges as_tidygraph(ison_southern_women) # now let's make it a tidygraph tbl_graph object #> # A tbl_graph: 32 nodes and 93 edges @@ -171,44 +171,25 @@ as_network(ison_southern_women) # a network object #> #> No edge attributes as_matrix(ison_southern_women) # a matrix object -#> E1 E2 E3 E4 E5 E6 E7 E8 E9 E10 -#> EVELYN 1 1 1 1 1 1 0 1 1 0 -#> LAURA 1 1 1 0 1 1 1 1 0 0 -#> THERESA 0 1 1 1 1 1 1 1 1 0 -#> BRENDA 1 0 1 1 1 1 1 1 0 0 -#> CHARLOTTE 0 0 1 1 1 0 1 0 0 0 -#> FRANCES 0 0 1 0 1 1 0 1 0 0 -#> ELEANOR 0 0 0 0 1 1 1 1 0 0 -#> PEARL 0 0 0 0 0 1 0 1 1 0 -#> RUTH 0 0 0 0 1 0 1 1 1 0 -#> VERNE 0 0 0 0 0 0 1 1 1 0 -#> MYRA 0 0 0 0 0 0 0 1 1 1 -#> KATHERINE 0 0 0 0 0 0 0 1 1 1 -#> SYLVIA 0 0 0 0 0 0 1 1 1 1 -#> NORA 0 0 0 0 0 1 1 0 1 1 -#> HELEN 0 0 0 0 0 0 1 1 0 1 -#> DOROTHY 0 0 0 0 0 0 0 1 1 1 -#> OLIVIA 0 0 0 0 0 0 0 0 1 0 -#> FLORA 0 0 0 0 0 0 0 0 1 0 -#> E11 E12 E13 E14 -#> EVELYN 0 0 0 0 -#> LAURA 0 0 0 0 -#> THERESA 0 0 0 0 -#> BRENDA 0 0 0 0 -#> CHARLOTTE 0 0 0 0 -#> FRANCES 0 0 0 0 -#> ELEANOR 0 0 0 0 -#> PEARL 0 0 0 0 -#> RUTH 0 0 0 0 -#> VERNE 0 1 0 0 -#> MYRA 0 1 0 0 -#> KATHERINE 0 1 1 1 -#> SYLVIA 0 1 1 1 -#> NORA 1 1 1 1 -#> HELEN 1 1 1 1 -#> DOROTHY 0 1 0 0 -#> OLIVIA 1 0 0 0 -#> FLORA 1 0 0 0 +#> E1 E2 E3 E4 E5 E6 E7 E8 E9 E10 E11 E12 E13 E14 +#> EVELYN 1 1 1 1 1 1 0 1 1 0 0 0 0 0 +#> LAURA 1 1 1 0 1 1 1 1 0 0 0 0 0 0 +#> THERESA 0 1 1 1 1 1 1 1 1 0 0 0 0 0 +#> BRENDA 1 0 1 1 1 1 1 1 0 0 0 0 0 0 +#> CHARLOTTE 0 0 1 1 1 0 1 0 0 0 0 0 0 0 +#> FRANCES 0 0 1 0 1 1 0 1 0 0 0 0 0 0 +#> ELEANOR 0 0 0 0 1 1 1 1 0 0 0 0 0 0 +#> PEARL 0 0 0 0 0 1 0 1 1 0 0 0 0 0 +#> RUTH 0 0 0 0 1 0 1 1 1 0 0 0 0 0 +#> VERNE 0 0 0 0 0 0 1 1 1 0 0 1 0 0 +#> MYRA 0 0 0 0 0 0 0 1 1 1 0 1 0 0 +#> KATHERINE 0 0 0 0 0 0 0 1 1 1 0 1 1 1 +#> SYLVIA 0 0 0 0 0 0 1 1 1 1 0 1 1 1 +#> NORA 0 0 0 0 0 1 1 0 1 1 1 1 1 1 +#> HELEN 0 0 0 0 0 0 1 1 0 1 1 1 1 1 +#> DOROTHY 0 0 0 0 0 0 0 1 1 1 0 1 0 0 +#> OLIVIA 0 0 0 0 0 0 0 0 1 0 1 0 0 0 +#> FLORA 0 0 0 0 0 0 0 0 1 0 1 0 0 0 # this is an incidence matrix since it is a two-mode network # if it were a one-mode network, the function would return an adjacency matrix as_edgelist(ison_southern_women) # an edgelist data frame/tibble @@ -265,19 +246,16 @@ to_unnamed(ison_marvel_relationships) #> # An undirected multigraph with 4 components #> # #> # Node Data: 53 × 9 (active) -#> Gender Appear… Attrac… Rich Intell… -#> -#> 1 Male 427 0 0 1 -#> 2 Male 589 1 0 1 -#> 3 Male 1207 0 0 1 -#> 4 Male 7609 1 0 1 -#> 5 Male 2189 1 1 1 -#> 6 Female 2907 1 0 1 -#> # … with 47 more rows, and 4 more -#> # variables: Omnilingual , -#> # PowerOrigin , -#> # UnarmedCombat , -#> # ArmedCombat +#> Gender Appear… Attrac… Rich Intell… Omnili… PowerO… +#> +#> 1 Male 427 0 0 1 1 Radiat… +#> 2 Male 589 1 0 1 0 Human +#> 3 Male 1207 0 0 1 1 Mutant +#> 4 Male 7609 1 0 1 0 Mutant +#> 5 Male 2189 1 1 1 0 Human +#> 6 Female 2907 1 0 1 0 Human +#> # … with 47 more rows, and 2 more variables: +#> # UnarmedCombat , ArmedCombat #> # #> # Edge Data: 558 × 3 #> from to sign @@ -294,12 +272,12 @@ to_named(ison_algebra) #> # Node Data: 16 × 1 (active) #> name #> -#> 1 Dustin -#> 2 Roberto -#> 3 Orville -#> 4 Ashlee -#> 5 Debora -#> 6 Grant +#> 1 Chris +#> 2 Manuel +#> 3 Tom +#> 4 Carlos +#> 5 Leonard +#> 6 Clara #> # … with 10 more rows #> # #> # Edge Data: 144 × 5 @@ -338,18 +316,16 @@ to_unsigned(ison_marvel_relationships, keep = "positive") #> # An undirected simple graph with 6 components #> # #> # Node Data: 53 × 10 (active) -#> name Gender Appear… Attrac… Rich -#> -#> 1 Abom… Male 427 0 0 -#> 2 Ant-… Male 589 1 0 -#> 3 Apoc… Male 1207 0 0 -#> 4 Beast Male 7609 1 0 -#> 5 Blac… Male 2189 1 1 -#> 6 Blac… Female 2907 1 0 -#> # … with 47 more rows, and 5 more -#> # variables: Intellect , -#> # Omnilingual , PowerOrigin , -#> # UnarmedCombat , +#> name Gender Appear… Attrac… Rich Intell… Omnili… +#> +#> 1 Abom… Male 427 0 0 1 1 +#> 2 Ant-… Male 589 1 0 1 0 +#> 3 Apoc… Male 1207 0 0 1 1 +#> 4 Beast Male 7609 1 0 1 0 +#> 5 Blac… Male 2189 1 1 1 0 +#> 6 Blac… Female 2907 1 0 1 0 +#> # … with 47 more rows, and 3 more variables: +#> # PowerOrigin , UnarmedCombat , #> # ArmedCombat #> # #> # Edge Data: 277 × 2 @@ -366,30 +342,30 @@ Note that for two-mode networks, there are also functions for converting or 'pro ```r to_mode1(ison_southern_women) -#> IGRAPH 22634be UNW- 18 139 -- +#> IGRAPH c911999 UNW- 18 139 -- #> + attr: name (v/c), weight (e/n) -#> + edges from 22634be (vertex names): -#> [1] EVELYN--LAURA EVELYN--BRENDA -#> [3] EVELYN--THERESA EVELYN--CHARLOTTE -#> [5] EVELYN--FRANCES EVELYN--ELEANOR -#> [7] EVELYN--RUTH EVELYN--PEARL -#> [9] EVELYN--NORA EVELYN--VERNE -#> [11] EVELYN--MYRA EVELYN--KATHERINE -#> [13] EVELYN--SYLVIA EVELYN--HELEN -#> [15] EVELYN--DOROTHY EVELYN--OLIVIA +#> + edges from c911999 (vertex names): +#> [1] EVELYN--LAURA EVELYN--BRENDA EVELYN--THERESA +#> [4] EVELYN--CHARLOTTE EVELYN--FRANCES EVELYN--ELEANOR +#> [7] EVELYN--RUTH EVELYN--PEARL EVELYN--NORA +#> [10] EVELYN--VERNE EVELYN--MYRA EVELYN--KATHERINE +#> [13] EVELYN--SYLVIA EVELYN--HELEN EVELYN--DOROTHY +#> [16] EVELYN--OLIVIA EVELYN--FLORA LAURA --BRENDA +#> [19] LAURA --THERESA LAURA --CHARLOTTE LAURA --FRANCES +#> [22] LAURA --ELEANOR LAURA --RUTH LAURA --PEARL #> + ... omitted several edges to_mode2(ison_southern_women) -#> IGRAPH 54edf77 UNW- 14 66 -- +#> IGRAPH 7f7d9ee UNW- 14 66 -- #> + attr: name (v/c), weight (e/n) -#> + edges from 54edf77 (vertex names): -#> [1] E1--E2 E1--E3 E1--E4 E1--E5 -#> [5] E1--E6 E1--E8 E1--E9 E1--E7 -#> [9] E2--E3 E2--E4 E2--E5 E2--E6 -#> [13] E2--E8 E2--E9 E2--E7 E3--E4 -#> [17] E3--E5 E3--E6 E3--E8 E3--E9 -#> [21] E3--E7 E4--E5 E4--E6 E4--E8 -#> [25] E4--E9 E4--E7 E5--E6 E5--E8 -#> [29] E5--E9 E5--E7 E6--E8 E6--E9 +#> + edges from 7f7d9ee (vertex names): +#> [1] E1--E2 E1--E3 E1--E4 E1--E5 E1--E6 E1--E8 +#> [7] E1--E9 E1--E7 E2--E3 E2--E4 E2--E5 E2--E6 +#> [13] E2--E8 E2--E9 E2--E7 E3--E4 E3--E5 E3--E6 +#> [19] E3--E8 E3--E9 E3--E7 E4--E5 E4--E6 E4--E8 +#> [25] E4--E9 E4--E7 E5--E6 E5--E8 E5--E9 E5--E7 +#> [31] E6--E8 E6--E9 E6--E7 E6--E10 E6--E11 E6--E12 +#> [37] E6--E13 E6--E14 E7--E8 E7--E9 E7--E12 E7--E10 +#> [43] E7--E13 E7--E14 E7--E11 E8--E9 E8--E12 E8--E10 #> + ... omitted several edges ``` @@ -417,18 +393,16 @@ as_tidygraph(mpn_elite_mex) %>% #> # An undirected simple graph with 1 component #> # #> # Node Data: 35 × 11 (active) -#> name full_n… entry_… milita… in_mpn -#> -#> 1 Trev… Trevin… 1910 1 0 -#> 2 Made… Madero… 1911 0 0 -#> 3 Carr… Carran… 1913 1 0 -#> 4 Agui… Aguila… 1918 1 0 -#> 5 Obre… Obrego… 1920 1 0 -#> 6 Call… Calles… 1924 1 0 -#> # … with 29 more rows, and 6 more -#> # variables: PlaceOfBirth , -#> # state , region , -#> # order , color , +#> name full_n… entry_… milita… in_mpn PlaceO… state +#> +#> 1 Trev… Trevin… 1910 1 0 Guerre… Coah… +#> 2 Made… Madero… 1911 0 0 Parras… Coah… +#> 3 Carr… Carran… 1913 1 0 Cuatro… Coah… +#> 4 Agui… Aguila… 1918 1 0 Cordoba Vera… +#> 5 Obre… Obrego… 1920 1 0 Siquis… Sono… +#> 6 Call… Calles… 1924 1 0 Guaymas Sono… +#> # … with 29 more rows, and 4 more variables: +#> # region , order , color , #> # degree #> # #> # Edge Data: 117 × 2 @@ -453,20 +427,20 @@ then you will need to use `join_ties()`: ```r generate_random(10, .3) %>% join_ties(generate_random(10, .3), "next") -#> # A tbl_graph: 10 nodes and 22 edges +#> # A tbl_graph: 10 nodes and 28 edges #> # #> # An undirected simple graph with 1 component #> # #> # Node Data: 10 × 0 (active) #> # … with 4 more rows #> # -#> # Edge Data: 22 × 4 +#> # Edge Data: 28 × 4 #> from to orig `next` #> #> 1 1 2 0 1 -#> 2 1 5 1 0 -#> 3 1 6 1 1 -#> # … with 19 more rows +#> 2 1 4 0 1 +#> 3 1 9 1 0 +#> # … with 25 more rows ``` ## Retrieving data @@ -477,112 +451,74 @@ Here too `{migraph}` has you covered. ```r node_names(mpn_elite_mex) # gets the names of the nodes -#> [1] "Trevino" -#> [2] "Madero" -#> [3] "Carranza" -#> [4] "Aguilar" -#> [5] "Obregon" -#> [6] "Calles" -#> [7] "Aleman Gonzalez" -#> [8] "Portes Gil" -#> [9] "L. Cardenas" -#> [10] "Avila Camacho" -#> [11] "I. Beteta" -#> [12] "Jara" -#> [13] "R. Beteta" -#> [14] "Aleman Valdes" -#> [15] "Sanchez Taboada" -#> [16] "Serra Rojas" -#> [17] "Ruiz Galindo" -#> [18] "Bustamante" -#> [19] "Loyo" -#> [20] "Carvajal" -#> [21] "Ruiz Cortines" -#> [22] "Carrillo Flores" -#> [23] "Ortiz Mena" -#> [24] "Gonzalez Blanco" -#> [25] "Salinas Lozano" -#> [26] "Lopez Mateos" -#> [27] "Margain" -#> [28] "Diaz Ordaz" -#> [29] "M.R. Beteta" -#> [30] "Echeverria Alvarez" -#> [31] "Lopez Portillo" -#> [32] "C. Cardenas" -#> [33] "De la Madrid" -#> [34] "Salinas de Gortari" +#> [1] "Trevino" "Madero" +#> [3] "Carranza" "Aguilar" +#> [5] "Obregon" "Calles" +#> [7] "Aleman Gonzalez" "Portes Gil" +#> [9] "L. Cardenas" "Avila Camacho" +#> [11] "I. Beteta" "Jara" +#> [13] "R. Beteta" "Aleman Valdes" +#> [15] "Sanchez Taboada" "Serra Rojas" +#> [17] "Ruiz Galindo" "Bustamante" +#> [19] "Loyo" "Carvajal" +#> [21] "Ruiz Cortines" "Carrillo Flores" +#> [23] "Ortiz Mena" "Gonzalez Blanco" +#> [25] "Salinas Lozano" "Lopez Mateos" +#> [27] "Margain" "Diaz Ordaz" +#> [29] "M.R. Beteta" "Echeverria Alvarez" +#> [31] "Lopez Portillo" "C. Cardenas" +#> [33] "De la Madrid" "Salinas de Gortari" #> [35] "Aleman Velasco" node_attribute(ison_marvel_relationships, "Gender") # gets any named nodal attribute -#> [1] "Male" "Male" "Male" "Male" -#> [5] "Male" "Female" "Male" "Male" -#> [9] "Male" "Male" "Male" "Male" -#> [13] "Male" "Male" "Male" "Male" -#> [17] "Male" "Female" "Male" "Male" -#> [21] "Male" "Male" "Male" "Male" -#> [25] "Female" "Male" "Male" "Female" -#> [29] "Female" "Male" "Male" "Female" -#> [33] "Female" "Male" "Male" "Male" -#> [37] "Female" "Male" "Male" "Male" -#> [41] "Male" "Male" "Male" "Female" -#> [45] "Male" "Male" "Female" "Male" -#> [49] "Male" "Male" "Male" "Male" -#> [53] "Male" +#> [1] "Male" "Male" "Male" "Male" "Male" "Female" +#> [7] "Male" "Male" "Male" "Male" "Male" "Male" +#> [13] "Male" "Male" "Male" "Male" "Male" "Female" +#> [19] "Male" "Male" "Male" "Male" "Male" "Male" +#> [25] "Female" "Male" "Male" "Female" "Female" "Male" +#> [31] "Male" "Female" "Female" "Male" "Male" "Male" +#> [37] "Female" "Male" "Male" "Male" "Male" "Male" +#> [43] "Male" "Female" "Male" "Male" "Female" "Male" +#> [49] "Male" "Male" "Male" "Male" "Male" tie_attribute(ison_marvel_relationships, "sign") # gets any named edge attribute -#> [1] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -#> [13] 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -#> [25] -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 -#> [37] 1 1 1 1 1 1 1 1 1 1 1 1 -#> [49] 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -#> [61] -1 -1 1 1 1 1 1 1 1 1 1 1 -#> [73] 1 1 1 1 1 1 1 1 1 1 1 -1 -#> [85] -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -#> [97] 1 1 1 1 1 1 1 1 1 -1 -1 -1 -#> [109] -1 -1 -1 1 1 1 1 1 1 1 1 -1 -#> [121] -1 -1 -1 1 1 1 1 1 1 1 1 1 -#> [133] 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -#> [145] -1 -1 -1 -1 -1 1 1 1 1 1 1 1 -#> [157] 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 -#> [169] 1 1 1 1 1 1 1 1 1 1 1 1 -#> [181] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -#> [193] 1 1 1 1 1 1 1 1 1 -1 -1 -1 -#> [205] -1 -1 -1 1 1 1 1 1 1 1 1 1 -#> [217] -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 -#> [229] 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -#> [241] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -#> [253] -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -#> [265] 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -#> [277] 1 1 -1 1 1 1 -1 -1 -1 -1 -1 -1 -#> [289] -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -#> [301] 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 -#> [313] 1 1 -1 1 1 1 1 1 1 1 1 1 -#> [325] -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 -#> [337] 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -#> [349] -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -#> [361] 1 1 1 1 1 1 1 1 1 -1 -1 -1 -#> [373] -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 -#> [385] 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -#> [397] -1 -1 -1 1 1 1 1 1 1 1 1 1 -#> [409] 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -#> [421] 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -#> [433] -1 1 1 -1 -1 1 1 1 1 1 1 -1 -#> [445] -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -#> [457] -1 -1 -1 -1 1 1 1 1 1 1 1 -1 -#> [469] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -#> [481] 1 1 1 -1 -1 -1 -1 -1 1 1 1 1 -#> [493] 1 -1 -1 1 1 1 1 1 1 1 -1 1 -#> [505] 1 1 1 -1 1 1 1 -1 -1 -1 -1 -1 -#> [517] -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -#> [529] -1 1 1 1 1 -1 -1 1 1 1 1 1 -#> [541] -1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 -#> [553] -1 -1 1 -1 1 -1 +#> [1] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 +#> [18] -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 +#> [35] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +#> [52] 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 +#> [69] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 -1 +#> [86] -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 1 +#> [103] 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 +#> [120] -1 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 +#> [137] 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 +#> [154] 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 +#> [171] 1 1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 +#> [188] -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 1 -1 -1 -1 +#> [205] -1 -1 -1 1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 +#> [222] -1 -1 -1 1 1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 +#> [239] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 +#> [256] -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 +#> [273] -1 -1 -1 -1 1 1 -1 1 1 1 -1 -1 -1 -1 -1 -1 -1 +#> [290] -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1 -1 -1 +#> [307] -1 -1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 +#> [324] 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 +#> [341] 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +#> [358] 1 1 1 1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 +#> [375] -1 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 1 -1 +#> [392] -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 1 +#> [409] 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 +#> [426] -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 1 1 +#> [443] 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 +#> [460] -1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +#> [477] -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 1 1 1 1 1 +#> [494] -1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 -1 1 1 +#> [511] 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 +#> [528] -1 -1 1 1 1 1 -1 -1 1 1 1 1 1 -1 -1 -1 1 +#> [545] 1 1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 -1 tie_weights(mpn_elite_mex) -#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -#> [19] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -#> [37] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -#> [55] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -#> [73] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -#> [91] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -#> [109] 1 1 1 1 1 1 1 1 1 +#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +#> [27] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +#> [53] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +#> [79] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +#> [105] 1 1 1 1 1 1 1 1 1 1 1 1 1 ``` We can describe the network using similar functions. @@ -590,10 +526,10 @@ How many nodes in the network, or how many edges? ```r -graph_nodes(mpn_elite_mex) +network_nodes(mpn_elite_mex) #> [1] 35 -graph_ties(mpn_elite_mex) +network_ties(mpn_elite_mex) #> [1] 117 -graph_dims(mpn_elite_mex) +network_dims(mpn_elite_mex) #> [1] 35 ``` diff --git a/vignettes/p1data.Rmd.orig b/vignettes/p1data.Rmd.orig index 7262591c..b0dab4fd 100644 --- a/vignettes/p1data.Rmd.orig +++ b/vignettes/p1data.Rmd.orig @@ -13,6 +13,7 @@ vignette: > knitr::opts_chunk$set( collapse = TRUE, comment = "#>", + fig.cap = "", fig.path = "teaching/" ) ``` @@ -229,7 +230,7 @@ We can describe the network using similar functions. How many nodes in the network, or how many edges? ```{r dims} -graph_nodes(mpn_elite_mex) -graph_ties(mpn_elite_mex) -graph_dims(mpn_elite_mex) +network_nodes(mpn_elite_mex) +network_ties(mpn_elite_mex) +network_dims(mpn_elite_mex) ``` diff --git a/vignettes/p2visualisation.Rmd b/vignettes/p2visualisation.Rmd new file mode 100644 index 00000000..1f4e7069 --- /dev/null +++ b/vignettes/p2visualisation.Rmd @@ -0,0 +1,232 @@ +--- +title: "2. Visualisation" +author: "James Hollway" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{2. Visualisation} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + + +# Why we graph + +Network visualisation is important and non-trivial. +As Tufte (1983: 9) said: + +> "At their best, graphics are instruments for reasoning about quantitative information. Often the most effective way to describe, explore, and summarize a set of numbers – even a very large set – is to look at pictures of those numbers" + +Brandes et al (1999) argue that visualising networks demands thinking about: + +- _substance_: a concise and precise delivery of insights to the researcher and/or readers +- _design_: the ergonomics of function are 98% of the purpose of good design, aesthetics only 2% +- and _algorithm_: the features of the e.g. the layout algorithm + +While there may be many dead-ends to exploratory visualisation, +it is worth taking the time to make sure that your main points are +easy to appreciate. + +On [her excellent and helpful website](https://kateto.net/network-visualization), +Katya Ognyanova outlines some key dimensions of control +that network researchers have to play with: + +- vertex position (layout) +- vertex shape +- vertex color +- vertex size +- vertex labels +- edge color +- edge size +- edge shape +- edge arrows + +# Approaches to visualising networks in R + +There are a host of packages for plotting in R, +and for plotting networks in R. +Plotting in R is typically based around two main approaches: +the 'base' approach in R by default, +and the 'grid' approach made popular by the famous and very flexible `{ggplot2}` package.^['gg' stands for the Grammar of Graphics.] +Approaches to plotting _graphs_ or _networks_ in R can be similarly divided. + +The two classic packages are `{igraph}` and `{sna}`, both building upon the base R graphics engine. +Newer packages [`{ggnetwork}`](https://www.r-bloggers.com/2016/03/ggnetwork-network-geometries-for-ggplot2/) and +[`{ggraph}`](https://ggraph.data-imaginist.com/index.html) build upon a grid approach.^[ +Others include: 'Networkly' for creating 2-D and 3-D interactive networks +that can be rendered with plotly and can be easily integrated into +shiny apps or markdown documents; +'visNetwork' interacts with javascript (vis.js) to make interactive networks +(http://datastorm-open.github.io/visNetwork/); and +'networkD3' interacts with javascript (D3) to make interactive networks +(https://www.r-bloggers.com/2016/10/network-visualization-part-6-d3-and-r-networkd3/). +] +This vignette introduces some functions in the `{migraph}` package for plotting and +visualising network data. +`{migraph}` builds upon the ggplot2/ggraph engine for plotting. + +# Using `{migraph}` to quickly plot network graphs + +To get a basic visualisation of the network before adding various specifications, +the `autographr()` function in `{migraph}` is a quick and easy way +to obtain a clear first look of the network +for preliminary investigations and understanding of the network. + + +```r +library(migraph) +autographr(ison_brandes) +``` + +![](teaching/migrapheg-1.png) + +We can also specify the colours, groups, shapes, and sizes of nodes in +the `autographr()` function using the following parameters: + +* `node_colour` +* `node_shape` +* `node_size` + +## Appending more + +Append `ggtitle()` to add a title. +`{migraph}` works well with both `{ggplot2}` and `{ggraph}` functions +that can be appended to create more tailored visualisations +of the network. + + +```r +autographr(ison_adolescents, + labels = TRUE, + node_size = 1.5) + + ggtitle("Visualisation") +``` + +![](teaching/migraphexample2-1.png) + +`{migraph}` also uses the `{patchwork}` package for arranging +graphs together, e.g. side-by-side or above one another. +The syntax is quite straight forward and is used throughout these vignettes. + + +```r +autographr(ison_adolescents) + autographr(ison_algebra) +``` + +![](teaching/patchwork-1.png) + +```r +autographr(ison_adolescents) / autographr(ison_algebra) +``` + +![](teaching/patchwork-2.png) + +## Layouts + +A range of graph layouts are available across the `{igraph}`, `{graphlayouts}`, and `{migraph}` packages +that can be used together with `autographr()`. + + +```r +(autographr(ison_southern_women, layout = "bipartite") + ggtitle("bipartite") | +autographr(ison_southern_women, layout = "hierarchy") + ggtitle("hierarchy")) / +(autographr(ison_southern_women, layout = "concentric") + ggtitle("concentric") | + autographr(ison_southern_women, layout = "railway") + ggtitle("railway")) +``` + +![](teaching/layoutseg-1.png) + +# Using `{ggraph}` for more flexibility + +For more flexibility with visualizations, +`{migraph}` users are encouraged to use the excellent `{ggraph}` package. +`{ggraph}` is built upon the venerable `{ggplot2}` package +and works with `tbl_graph` and `igraph` objects. +As with `{ggplot2}`, `{ggraph}` users are expected to build +a particular plot from the ground up, +adding explicit layers to visualise the nodes and edges. + + +```r +library(ggraph) +ggraph(mpn_elite_mex, layout = "fr") + + geom_edge_link(edge_colour = "dark grey", + arrow = arrow(angle = 45, + length = unit(2, "mm"), + type = "closed"), + end_cap = circle(3, "mm")) + + geom_node_point(size = 2.5, shape = 19, colour = "blue") + + geom_node_text(aes(label=name), family = "serif", size = 2.5) + + scale_edge_width(range = c(0.3,1.5)) + + theme_graph() + + theme(legend.position = "none") +``` + +![](teaching/ggrapheg-1.png) + +As we can see in the code above, we can specify various aspects of the plot to +tailor it to our network. +Firstly, we can alter the **layout** of the network using the `layout =` argument +to create a clearer visualisation of the ties between nodes. +This is especially important for larger networks, where nodes and ties are more +easily obscured or misrepresented. +In `{ggraph}`, the default layout is the "stress" layout. +The "stress" layout is a safe choice because it is deterministic and +fits well with almost any graph, but it is also a good idea to explore and try +out other layouts on your data. +More layouts can be found in the `{graphlayouts}` and `{igraph}` R packages. +To use a layout from the `{igraph}` package, enter only the last part of the layout +algorithm name (eg. `layout = "mds"` for "layout_with_mds"). + +Secondly, using `geom_node_point()` which draws the nodes as geometric shapes +(circles, squares, or triangles), we can specify the presentation of **nodes** +in the network in terms of their *shape* (`shape=`, choose from 1 to 21), +*size* (`size=`), or *colour* (`colour=`). We can also use `aes()` to match to +node attributes. To add labels, use `geom_node_text()` or +`geom_node_label()` (draws labels within a box). The font (`family=`), +font size (`size=`), and colour (`colour=`) of the labels can be specified. + +Thirdly, we can also specify the presentation of **edges** in the network. +To draw edges, we use `geom_edge_link0()` or `geom_edge_link()`. +Using the latter function makes it possible to draw a straight line with a +gradient. +The following features can be tailored either globally or matched to specific +edge attributes using `aes()`: + +* *colour*: `edge_colour=` + +* *width*: `edge_width=` + +* *linetype*: `edge_linetype=` + +* *opacity*: `edge_alpha=` + +For directed graphs, arrows can be drawn using the `arrow=` argument and the +`arrow()` function from `{ggplot2}`. The angle, length, arrowhead type, and +padding between the arrowhead and the node can also be specified. + +To change the position of the legend, add the `theme()` function from `{ggplot2}`. +The legend can be positioned at the top, bottom, left, or right, +or removed using "none". + +For more see David Schoch's [excellent resources on this](http://mr.schochastics.net/netVizR.html). + +# Exporting plots to PDF + +We can print the plots we have made to PDF by point-and-click +by selecting 'Save as PDF...' from under the 'Export' dropdown menu +in the plots panel tab of RStudio. + +If you want to do this programmatically, +say because you want to record how you have saved it so that you can +e.g. make some changes to the parameters at some point, +this is also not too difficult. + +After running the (gg-based) plot you want to save, +use the command `ggsave("my_filename.pdf")` to save your plot +as a PDF to your working directory. +If you want to save it somewhere else, you will need to specify the file path +(or change the working directory, but that might be more cumbersome). +If you want to save it as a different filetype, +replace `.pdf` with e.g. `.png` or `.jpeg`. +See `?ggsave` for more. diff --git a/vignettes/p2visualisation.Rmd.orig b/vignettes/p2visualisation.Rmd.orig new file mode 100644 index 00000000..06bc23ee --- /dev/null +++ b/vignettes/p2visualisation.Rmd.orig @@ -0,0 +1,219 @@ +--- +title: "2. Visualisation" +author: "James Hollway" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{2. Visualisation} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.cap = "", + fig.path = "teaching/" +) +``` + +# Why we graph + +Network visualisation is important and non-trivial. +As Tufte (1983: 9) said: + +> "At their best, graphics are instruments for reasoning about quantitative information. Often the most effective way to describe, explore, and summarize a set of numbers – even a very large set – is to look at pictures of those numbers" + +Brandes et al (1999) argue that visualising networks demands thinking about: + +- _substance_: a concise and precise delivery of insights to the researcher and/or readers +- _design_: the ergonomics of function are 98% of the purpose of good design, aesthetics only 2% +- and _algorithm_: the features of the e.g. the layout algorithm + +While there may be many dead-ends to exploratory visualisation, +it is worth taking the time to make sure that your main points are +easy to appreciate. + +On [her excellent and helpful website](https://kateto.net/network-visualization), +Katya Ognyanova outlines some key dimensions of control +that network researchers have to play with: + +- vertex position (layout) +- vertex shape +- vertex color +- vertex size +- vertex labels +- edge color +- edge size +- edge shape +- edge arrows + +# Approaches to visualising networks in R + +There are a host of packages for plotting in R, +and for plotting networks in R. +Plotting in R is typically based around two main approaches: +the 'base' approach in R by default, +and the 'grid' approach made popular by the famous and very flexible `{ggplot2}` package.^['gg' stands for the Grammar of Graphics.] +Approaches to plotting _graphs_ or _networks_ in R can be similarly divided. + +The two classic packages are `{igraph}` and `{sna}`, both building upon the base R graphics engine. +Newer packages [`{ggnetwork}`](https://www.r-bloggers.com/2016/03/ggnetwork-network-geometries-for-ggplot2/) and +[`{ggraph}`](https://ggraph.data-imaginist.com/index.html) build upon a grid approach.^[ +Others include: 'Networkly' for creating 2-D and 3-D interactive networks +that can be rendered with plotly and can be easily integrated into +shiny apps or markdown documents; +'visNetwork' interacts with javascript (vis.js) to make interactive networks +(http://datastorm-open.github.io/visNetwork/); and +'networkD3' interacts with javascript (D3) to make interactive networks +(https://www.r-bloggers.com/2016/10/network-visualization-part-6-d3-and-r-networkd3/). +] +This vignette introduces some functions in the `{migraph}` package for plotting and +visualising network data. +`{migraph}` builds upon the ggplot2/ggraph engine for plotting. + +# Using `{migraph}` to quickly plot network graphs + +To get a basic visualisation of the network before adding various specifications, +the `autographr()` function in `{migraph}` is a quick and easy way +to obtain a clear first look of the network +for preliminary investigations and understanding of the network. + +```{r migrapheg, echo=TRUE} +library(migraph) +autographr(ison_brandes) +``` + +We can also specify the colours, groups, shapes, and sizes of nodes in +the `autographr()` function using the following parameters: + +* `node_colour` +* `node_shape` +* `node_size` + +## Appending more + +Append `ggtitle()` to add a title. +`{migraph}` works well with both `{ggplot2}` and `{ggraph}` functions +that can be appended to create more tailored visualisations +of the network. + +```{r migraphexample2, echo=TRUE, message=FALSE, warning=FALSE} +autographr(ison_adolescents, + labels = TRUE, + node_size = 1.5) + + ggtitle("Visualisation") +``` + +`{migraph}` also uses the `{patchwork}` package for arranging +graphs together, e.g. side-by-side or above one another. +The syntax is quite straight forward and is used throughout these vignettes. + +```{r patchwork, echo=TRUE, message=FALSE, warning=FALSE} +autographr(ison_adolescents) + autographr(ison_algebra) +autographr(ison_adolescents) / autographr(ison_algebra) +``` + +## Layouts + +A range of graph layouts are available across the `{igraph}`, `{graphlayouts}`, and `{migraph}` packages +that can be used together with `autographr()`. + +```{r layoutseg, echo=TRUE, message=FALSE, warning=FALSE} +(autographr(ison_southern_women, layout = "bipartite") + ggtitle("bipartite") | +autographr(ison_southern_women, layout = "hierarchy") + ggtitle("hierarchy")) / +(autographr(ison_southern_women, layout = "concentric") + ggtitle("concentric") | + autographr(ison_southern_women, layout = "railway") + ggtitle("railway")) +``` + +# Using `{ggraph}` for more flexibility + +For more flexibility with visualizations, +`{migraph}` users are encouraged to use the excellent `{ggraph}` package. +`{ggraph}` is built upon the venerable `{ggplot2}` package +and works with `tbl_graph` and `igraph` objects. +As with `{ggplot2}`, `{ggraph}` users are expected to build +a particular plot from the ground up, +adding explicit layers to visualise the nodes and edges. + +```{r ggrapheg, echo=TRUE, message=FALSE, warning=FALSE} +library(ggraph) +ggraph(mpn_elite_mex, layout = "fr") + + geom_edge_link(edge_colour = "dark grey", + arrow = arrow(angle = 45, + length = unit(2, "mm"), + type = "closed"), + end_cap = circle(3, "mm")) + + geom_node_point(size = 2.5, shape = 19, colour = "blue") + + geom_node_text(aes(label=name), family = "serif", size = 2.5) + + scale_edge_width(range = c(0.3,1.5)) + + theme_graph() + + theme(legend.position = "none") +``` + +As we can see in the code above, we can specify various aspects of the plot to +tailor it to our network. +Firstly, we can alter the **layout** of the network using the `layout =` argument +to create a clearer visualisation of the ties between nodes. +This is especially important for larger networks, where nodes and ties are more +easily obscured or misrepresented. +In `{ggraph}`, the default layout is the "stress" layout. +The "stress" layout is a safe choice because it is deterministic and +fits well with almost any graph, but it is also a good idea to explore and try +out other layouts on your data. +More layouts can be found in the `{graphlayouts}` and `{igraph}` R packages. +To use a layout from the `{igraph}` package, enter only the last part of the layout +algorithm name (eg. `layout = "mds"` for "layout_with_mds"). + +Secondly, using `geom_node_point()` which draws the nodes as geometric shapes +(circles, squares, or triangles), we can specify the presentation of **nodes** +in the network in terms of their *shape* (`shape=`, choose from 1 to 21), +*size* (`size=`), or *colour* (`colour=`). We can also use `aes()` to match to +node attributes. To add labels, use `geom_node_text()` or +`geom_node_label()` (draws labels within a box). The font (`family=`), +font size (`size=`), and colour (`colour=`) of the labels can be specified. + +Thirdly, we can also specify the presentation of **edges** in the network. +To draw edges, we use `geom_edge_link0()` or `geom_edge_link()`. +Using the latter function makes it possible to draw a straight line with a +gradient. +The following features can be tailored either globally or matched to specific +edge attributes using `aes()`: + +* *colour*: `edge_colour=` + +* *width*: `edge_width=` + +* *linetype*: `edge_linetype=` + +* *opacity*: `edge_alpha=` + +For directed graphs, arrows can be drawn using the `arrow=` argument and the +`arrow()` function from `{ggplot2}`. The angle, length, arrowhead type, and +padding between the arrowhead and the node can also be specified. + +To change the position of the legend, add the `theme()` function from `{ggplot2}`. +The legend can be positioned at the top, bottom, left, or right, +or removed using "none". + +For more see David Schoch's [excellent resources on this](http://mr.schochastics.net/netVizR.html). + +# Exporting plots to PDF + +We can print the plots we have made to PDF by point-and-click +by selecting 'Save as PDF...' from under the 'Export' dropdown menu +in the plots panel tab of RStudio. + +If you want to do this programmatically, +say because you want to record how you have saved it so that you can +e.g. make some changes to the parameters at some point, +this is also not too difficult. + +After running the (gg-based) plot you want to save, +use the command `ggsave("my_filename.pdf")` to save your plot +as a PDF to your working directory. +If you want to save it somewhere else, you will need to specify the file path +(or change the working directory, but that might be more cumbersome). +If you want to save it as a different filetype, +replace `.pdf` with e.g. `.png` or `.jpeg`. +See `?ggsave` for more. diff --git a/vignettes/p3centrality.Rmd b/vignettes/p3centrality.Rmd index 9e13b24d..26a670c7 100644 --- a/vignettes/p3centrality.Rmd +++ b/vignettes/p3centrality.Rmd @@ -24,40 +24,40 @@ library(migraph) autographr(ison_brandes) ``` -![plot of chunk coercion](teaching/coercion-1.png) +![](teaching/coercion-1.png) ```r autographr(ison_brandes2) ``` -![plot of chunk coercion](teaching/coercion-2.png) +![](teaching/coercion-2.png) ```r (mat <- as_matrix(ison_brandes)) -#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] -#> [1,] 0 0 1 0 0 0 0 -#> [2,] 0 0 1 0 0 0 0 -#> [3,] 1 1 0 1 0 0 0 -#> [4,] 0 0 1 0 1 1 0 -#> [5,] 0 0 0 1 0 0 1 -#> [6,] 0 0 0 1 0 0 1 -#> [7,] 0 0 0 0 1 1 0 -#> [8,] 0 0 0 0 0 1 0 -#> [9,] 0 0 0 0 0 0 1 -#> [10,] 0 0 0 0 0 0 0 -#> [11,] 0 0 0 0 0 0 0 -#> [,8] [,9] [,10] [,11] -#> [1,] 0 0 0 0 -#> [2,] 0 0 0 0 -#> [3,] 0 0 0 0 -#> [4,] 0 0 0 0 -#> [5,] 0 0 0 0 -#> [6,] 1 0 0 0 -#> [7,] 0 1 0 0 -#> [8,] 0 1 0 0 -#> [9,] 1 0 1 1 -#> [10,] 0 1 0 0 -#> [11,] 0 1 0 0 +#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] +#> [1,] 0 0 1 0 0 0 0 0 0 +#> [2,] 0 0 1 0 0 0 0 0 0 +#> [3,] 1 1 0 1 0 0 0 0 0 +#> [4,] 0 0 1 0 1 1 0 0 0 +#> [5,] 0 0 0 1 0 0 1 0 0 +#> [6,] 0 0 0 1 0 0 1 1 0 +#> [7,] 0 0 0 0 1 1 0 0 1 +#> [8,] 0 0 0 0 0 1 0 0 1 +#> [9,] 0 0 0 0 0 0 1 1 0 +#> [10,] 0 0 0 0 0 0 0 0 1 +#> [11,] 0 0 0 0 0 0 0 0 1 +#> [,10] [,11] +#> [1,] 0 0 +#> [2,] 0 0 +#> [3,] 0 0 +#> [4,] 0 0 +#> [5,] 0 0 +#> [6,] 0 0 +#> [7,] 0 0 +#> [8,] 0 0 +#> [9,] 1 1 +#> [10,] 0 0 +#> [11,] 0 0 ``` The network is anonymous, but I think it would be nice to add some names, @@ -72,7 +72,7 @@ ison_brandes2 <- to_named(ison_brandes2) autographr(ison_brandes) ``` -![plot of chunk addingnames](teaching/addingnames-1.png) +![](teaching/addingnames-1.png) Note that you will likely get a different set of names, as they are assigned randomly from a pool of (American) first names. @@ -85,14 +85,14 @@ Just sum the rows or columns of the matrix! (degrees <- rowSums(mat)) #> [1] 1 1 3 3 2 3 3 2 4 1 1 rowSums(mat) == colSums(mat) -#> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE -#> [8] TRUE TRUE TRUE TRUE +#> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE +#> [10] TRUE TRUE # Are they all equal? Why? # You can also just use a built in command in migraph though: node_degree(ison_brandes, normalized = FALSE) -#> Kelly Bentley Clifford Lily Ivan Debra -#> 1 1 1 3 3 2 3 -#> # ... with 5 more from this nodeset in the vector. +#> Melinda Haley Mallory Pamela Florence Cora Olga +#> 1 1 1 3 3 2 3 3 +#> # ... with 4 more from this nodeset in the vector. ``` Often we are interested in the distribution of (degree) centrality in a network. @@ -105,7 +105,7 @@ plot(node_degree(ison_brandes), "h") + plot(node_degree(ison_brandes), "d") ``` -![plot of chunk distrib](teaching/distrib-1.png) +![](teaching/distrib-1.png) Other measures of centrality can be a little trickier to calculate by hand. Fortunately, we can use functions from `{migraph}` to help: @@ -113,17 +113,17 @@ Fortunately, we can use functions from `{migraph}` to help: ```r node_betweenness(ison_brandes) -#> Kelly Bentley Clifford Lily Ivan Debra -#> 1 0 0 0.378 0.485 0.133 0.337 -#> # ... with 5 more from this nodeset in the vector. +#> Melinda Haley Mallory Pamela Florence Cora Olga +#> 1 0 0 0.378 0.485 0.133 0.337 0.304 +#> # ... with 4 more from this nodeset in the vector. node_closeness(ison_brandes) -#> Kelly Bentley Clifford Lily Ivan Debra -#> 1 0.278 0.278 0.370 0.455 0.435 0.476 -#> # ... with 5 more from this nodeset in the vector. +#> Melinda Haley Mallory Pamela Florence Cora Olga +#> 1 0.278 0.278 0.370 0.455 0.435 0.476 0.455 +#> # ... with 4 more from this nodeset in the vector. node_eigenvector(ison_brandes) -#> Kelly Bentley Clifford Lily Ivan Debra -#> 1 0.106 0.106 0.277 0.510 0.437 0.615 -#> # ... with 5 more from this nodeset in the vector. +#> Melinda Haley Mallory Pamela Florence Cora Olga +#> 1 0.106 0.106 0.277 0.510 0.437 0.615 0.631 +#> # ... with 4 more from this nodeset in the vector. # TASK: Can you create degree distributions for each of these? ``` @@ -149,7 +149,7 @@ ison_brandes %>% autographr(node_color = "color") ``` -![plot of chunk ggid](teaching/ggid-1.png) +![](teaching/ggid-1.png) ```r ison_brandes %>% @@ -157,7 +157,7 @@ ison_brandes %>% autographr(node_color = "color") ``` -![plot of chunk ggid](teaching/ggid-2.png) +![](teaching/ggid-2.png) ```r ison_brandes %>% @@ -165,7 +165,7 @@ ison_brandes %>% autographr(node_color = "color") ``` -![plot of chunk ggid](teaching/ggid-3.png) +![](teaching/ggid-3.png) ```r ison_brandes %>% @@ -173,7 +173,7 @@ ison_brandes %>% autographr(node_color = "color") ``` -![plot of chunk ggid](teaching/ggid-4.png) +![](teaching/ggid-4.png) How neat! Try it with the two-mode version. What can you see? @@ -186,13 +186,13 @@ but in the level of the whole graph, so the syntax is: ```r -graph_degree(ison_brandes) +network_degree(ison_brandes) #> [1] 0.182 -graph_betweenness(ison_brandes) +network_betweenness(ison_brandes) #> [1] 0.318 -graph_closeness(ison_brandes) +network_closeness(ison_brandes) #> [1] 0.23 -graph_eigenvector(ison_brandes) +network_eigenvector(ison_brandes) #> [1] 0.484 ``` @@ -217,17 +217,17 @@ ison_brandes <- ison_brandes %>% add_node_attribute("closeness", node_is_max(node_closeness(ison_brandes))) %>% add_node_attribute("eigenvector", node_is_max(node_eigenvector(ison_brandes))) gd <- autographr(ison_brandes, node_color = "degree") + - ggtitle("Degree", subtitle = round(graph_degree(ison_brandes), 2)) + ggtitle("Degree", subtitle = round(network_degree(ison_brandes), 2)) gc <- autographr(ison_brandes, node_color = "closeness") + - ggtitle("Closeness", subtitle = round(graph_closeness(ison_brandes), 2)) + ggtitle("Closeness", subtitle = round(network_closeness(ison_brandes), 2)) gb <- autographr(ison_brandes, node_color = "betweenness") + - ggtitle("Betweenness", subtitle = round(graph_betweenness(ison_brandes), 2)) + ggtitle("Betweenness", subtitle = round(network_betweenness(ison_brandes), 2)) ge <- autographr(ison_brandes, node_color = "eigenvector") + - ggtitle("Eigenvector", subtitle = round(graph_eigenvector(ison_brandes), 2)) + ggtitle("Eigenvector", subtitle = round(network_eigenvector(ison_brandes), 2)) (gd | gb) / (gc | ge) ``` -![plot of chunk multiplot](teaching/multiplot-1.png) +![](teaching/multiplot-1.png) ```r # ggsave("brandes-centralities.pdf") diff --git a/vignettes/p3centrality.Rmd.orig b/vignettes/p3centrality.Rmd.orig index 7bf0afe2..2687a308 100644 --- a/vignettes/p3centrality.Rmd.orig +++ b/vignettes/p3centrality.Rmd.orig @@ -13,6 +13,7 @@ vignette: > knitr::opts_chunk$set( collapse = TRUE, comment = "#>", + fig.cap = "", fig.path = "teaching/" ) ``` @@ -116,10 +117,10 @@ Here we are no longer interested in the level of the node, but in the level of the whole graph, so the syntax is: ```{r centzn} -graph_degree(ison_brandes) -graph_betweenness(ison_brandes) -graph_closeness(ison_brandes) -graph_eigenvector(ison_brandes) +network_degree(ison_brandes) +network_betweenness(ison_brandes) +network_closeness(ison_brandes) +network_eigenvector(ison_brandes) ``` By default, scores are printed to 3 decimal places, @@ -142,13 +143,13 @@ ison_brandes <- ison_brandes %>% add_node_attribute("closeness", node_is_max(node_closeness(ison_brandes))) %>% add_node_attribute("eigenvector", node_is_max(node_eigenvector(ison_brandes))) gd <- autographr(ison_brandes, node_color = "degree") + - ggtitle("Degree", subtitle = round(graph_degree(ison_brandes), 2)) + ggtitle("Degree", subtitle = round(network_degree(ison_brandes), 2)) gc <- autographr(ison_brandes, node_color = "closeness") + - ggtitle("Closeness", subtitle = round(graph_closeness(ison_brandes), 2)) + ggtitle("Closeness", subtitle = round(network_closeness(ison_brandes), 2)) gb <- autographr(ison_brandes, node_color = "betweenness") + - ggtitle("Betweenness", subtitle = round(graph_betweenness(ison_brandes), 2)) + ggtitle("Betweenness", subtitle = round(network_betweenness(ison_brandes), 2)) ge <- autographr(ison_brandes, node_color = "eigenvector") + - ggtitle("Eigenvector", subtitle = round(graph_eigenvector(ison_brandes), 2)) + ggtitle("Eigenvector", subtitle = round(network_eigenvector(ison_brandes), 2)) (gd | gb) / (gc | ge) # ggsave("brandes-centralities.pdf") ``` diff --git a/vignettes/p5equivalence.Rmd b/vignettes/p5equivalence.Rmd index e0cf8693..d1c28c57 100644 --- a/vignettes/p5equivalence.Rmd +++ b/vignettes/p5equivalence.Rmd @@ -110,7 +110,7 @@ gtask <- autographr(tasks) + ggtitle("Task") gfriend + gsocial + gtask ``` -![plot of chunk separatingnets](teaching/separatingnets-1.png) +![](teaching/separatingnets-1.png) Note also that these are weighted networks. `autographr()` automatically registers these different weights and plots them. @@ -125,9 +125,9 @@ by their position in the task network to begin with. ```r node_constraint(tasks) -#> Melinda Abby Darryl Veronica Rylan -#> 1 0.930 0.877 0.664 0.987 0.611 -#> # ... with 11 more from this nodeset in the vector. +#> Melinda Abby Darryl Veronica Rylan Lindsey Lula +#> 1 0.930 0.877 0.664 0.987 0.611 0.609 0.900 +#> # ... with 9 more from this nodeset in the vector. ``` We see that this function returns a vector of @@ -141,7 +141,7 @@ tasks <- tasks %>% mutate(low_constraint = node_is_min(node_constraint(tasks))) autographr(tasks, node_color = "low_constraint") ``` -![plot of chunk constraintplot](teaching/constraintplot-1.png) +![](teaching/constraintplot-1.png) Why minimum? And what can we learn from this plot about where innovation might occur within this network? @@ -174,7 +174,7 @@ ison_algebra %>% autographr(node_color = "se") ``` -![plot of chunk find-se](teaching/find-se-1.png) +![](teaching/find-se-1.png) But actually, a lot is going on behind the scenes here that we can unpack. @@ -190,31 +190,31 @@ both outgoing and incoming ties, to reveal their relationships to tie partners. ```r node_tie_census(ison_algebra) #> # A tibble: 16 × 96 -#> fromM…¹ fromA…² fromD…³ fromV…⁴ fromR…⁵ -#> -#> 1 0 1 0 0 1 -#> 2 0 0 0 0 0 -#> 3 0 0 0 0 1 -#> 4 0 0 0 0 0 -#> 5 0 0 1 0 0 -#> 6 0 0 1 0 1 -#> 7 0 1 0 0 0 -#> 8 0 1 0 0 1 -#> 9 0 0 0 0 0 -#> 10 0 0 0 0 1 -#> 11 0 0 1 0 2 -#> 12 0 0 0 0 0 -#> 13 0 2 0 0 0 -#> 14 0 1 1 0 0 -#> 15 0 0 1 0 0 -#> 16 0 0 0 0 0 -#> # … with 91 more variables: -#> # fromLindsey_friends , -#> # fromLula_friends , +#> fromMeli…¹ fromA…² fromD…³ fromV…⁴ fromR…⁵ fromL…⁶ +#> +#> 1 0 1 0 0 1 1 +#> 2 0 0 0 0 0 0 +#> 3 0 0 0 0 1 2 +#> 4 0 0 0 0 0 0 +#> 5 0 0 1 0 0 1 +#> 6 0 0 1 0 1 0 +#> 7 0 1 0 0 0 1 +#> 8 0 1 0 0 1 0 +#> 9 0 0 0 0 0 0 +#> 10 0 0 0 0 1 1 +#> 11 0 0 1 0 2 1 +#> 12 0 0 0 0 0 1 +#> 13 0 2 0 0 0 0 +#> 14 0 1 1 0 0 0 +#> 15 0 0 1 0 0 0 +#> 16 0 0 0 0 0 0 +#> # … with 90 more variables: fromLula_friends , #> # fromElva_friends , #> # fromMiriam_friends , #> # fromGeorge_friends , -#> # fromLuella_friends , … +#> # fromLuella_friends , +#> # fromDustin_friends , +#> # fromColleen_friends , … dim(node_tie_census(ison_algebra)) #> [1] 16 96 ``` @@ -257,19 +257,19 @@ by plotting the dendrograms (hidden) in the output from `node_structural_equival plot(node_structural_equivalence(ison_algebra, cluster = "hier", distance = "euclidean")) ``` -![plot of chunk vary-clust](teaching/vary-clust-1.png) +![](teaching/vary-clust-1.png) ```r plot(node_structural_equivalence(ison_algebra, cluster = "hier", distance = "manhattan")) ``` -![plot of chunk vary-clust](teaching/vary-clust-2.png) +![](teaching/vary-clust-2.png) ```r plot(node_structural_equivalence(ison_algebra, cluster = "concor")) ``` -![plot of chunk vary-clust](teaching/vary-clust-3.png) +![](teaching/vary-clust-3.png) So plotting a `membership` vector from `{migraph}` returns a dendrogram with the names of the nodes on the _y_-axis and the distance between them on the _x_-axis. @@ -314,7 +314,7 @@ We could set this ourselves by just passing `k` an integer. plot(node_structural_equivalence(ison_algebra, k = 2)) ``` -![plot of chunk k-discrete](teaching/k-discrete-1.png) +![](teaching/k-discrete-1.png) But we're really just guessing. Maybe 2 is not the best `k`? To establish that, we need to iterate through a number of potential `k`, @@ -359,13 +359,13 @@ See what we have here, with all other arguments held the same: plot(node_structural_equivalence(ison_algebra, k = "elbow")) ``` -![plot of chunk elbowsil](teaching/elbowsil-1.png) +![](teaching/elbowsil-1.png) ```r plot(node_structural_equivalence(ison_algebra, k = "silhouette")) ``` -![plot of chunk elbowsil](teaching/elbowsil-2.png) +![](teaching/elbowsil-2.png) Ok, so it looks like the elbow method returns `k == 3` as a good trade-off between fit and parsimony. @@ -395,7 +395,7 @@ despite some variation, can be considered as similar on some dimension. plot(node_structural_equivalence(ison_algebra, k = "strict")) ``` -![plot of chunk strict](teaching/strict-1.png) +![](teaching/strict-1.png) Here for example, no two nodes have precisely the same tie-profile, otherwise their branches would join/fork at a distance of 0. @@ -419,7 +419,7 @@ ison_algebra %>% autographr(node_color = "se") ``` -![plot of chunk strplot](teaching/strplot-1.png) +![](teaching/strplot-1.png) While this plot enters the class information in to our earlier graph, it doesn't always help us understand how the classes vary. @@ -437,19 +437,19 @@ but this can be tweaked by assigning some other summary statistic as `FUN = `. summary(node_tie_census(ison_algebra), membership = str_clu) #> # A tibble: 4 × 96 -#> fromMe…¹ fromA…² fromD…³ fromV…⁴ fromR…⁵ -#> -#> 1 0 0.167 0.167 0 0.333 -#> 2 0 1 0.2 0 0.2 -#> 3 0 0 0.75 0 1 -#> 4 0 0 0 0 0 -#> # … with 91 more variables: -#> # fromLindsey_friends , -#> # fromLula_friends , +#> fromMelin…¹ fromA…² fromD…³ fromV…⁴ fromR…⁵ fromL…⁶ +#> +#> 1 0 0.167 0.167 0 0.333 0.5 +#> 2 0 1 0.2 0 0.2 0.2 +#> 3 0 0 0.75 0 1 1 +#> 4 0 0 0 0 0 0 +#> # … with 90 more variables: fromLula_friends , #> # fromElva_friends , #> # fromMiriam_friends , #> # fromGeorge_friends , -#> # fromLuella_friends , … +#> # fromLuella_friends , +#> # fromDustin_friends , +#> # fromColleen_friends , … ``` Since this node census produces 96 columns, @@ -468,7 +468,7 @@ plot(as_matrix(ison_algebra), membership = str_clu) ``` -![plot of chunk block](teaching/block-1.png) +![](teaching/block-1.png) So, with this information, we might characterise them like so: @@ -521,7 +521,7 @@ bm <- bm %>% as_tidygraph %>% mutate(name = c("Freaks", "Squares", "Nerds", "Gee autographr(bm) ``` -![plot of chunk structblock](teaching/structblock-1.png) +![](teaching/structblock-1.png) # Unit Test diff --git a/vignettes/p5equivalence.Rmd.orig b/vignettes/p5equivalence.Rmd.orig index de1e59e9..898d4d4b 100644 --- a/vignettes/p5equivalence.Rmd.orig +++ b/vignettes/p5equivalence.Rmd.orig @@ -13,6 +13,7 @@ vignette: > knitr::opts_chunk$set( collapse = TRUE, comment = "#>", + fig.cap = "", fig.path = "teaching/" ) ``` diff --git a/vignettes/p7linearmodel.Rmd b/vignettes/p7linearmodel.Rmd index 263ec5df..7917851e 100644 --- a/vignettes/p7linearmodel.Rmd +++ b/vignettes/p7linearmodel.Rmd @@ -37,18 +37,16 @@ marvel_friends #> # An undirected simple graph with 1 component #> # #> # Node Data: 19 × 10 (active) -#> name Gender Appear… Attrac… Rich -#> -#> 1 Beast Male 7609 1 0 -#> 2 Capt… Male 9000 1 0 -#> 3 Colo… Male 5974 1 0 -#> 4 Cycl… Male 8853 1 0 -#> 5 Emma… Female 4777 1 0 -#> 6 Hawk… Male 3982 1 0 -#> # … with 13 more rows, and 5 more -#> # variables: Intellect , -#> # Omnilingual , PowerOrigin , -#> # UnarmedCombat , +#> name Gender Appear… Attrac… Rich Intell… Omnili… +#> +#> 1 Beast Male 7609 1 0 1 0 +#> 2 Capt… Male 9000 1 0 1 0 +#> 3 Colo… Male 5974 1 0 0 0 +#> 4 Cycl… Male 8853 1 0 1 0 +#> 5 Emma… Female 4777 1 0 0 1 +#> 6 Hawk… Male 3982 1 0 0 0 +#> # … with 13 more rows, and 3 more variables: +#> # PowerOrigin , UnarmedCombat , #> # ArmedCombat #> # #> # Edge Data: 107 × 2 @@ -71,7 +69,7 @@ autographr(marvel_friends, node_color = "PowerOrigin") ``` -![plot of chunk unnamed-chunk-2](teaching/unnamed-chunk-2-1.png) +![](teaching/unnamed-chunk-2-1.png) These variables seem to be distributed unevenly across the network. There seems to be some homophily, or like choosing like, @@ -97,15 +95,15 @@ would receive a score of 1. ```r -graph_diversity(marvel_friends, "Gender") +network_diversity(marvel_friends, "Gender") #> [1] 0.388 -graph_diversity(marvel_friends, "PowerOrigin") +network_diversity(marvel_friends, "PowerOrigin") #> [1] 0.593 -graph_diversity(marvel_friends, "Attractive") +network_diversity(marvel_friends, "Attractive") #> [1] 0.188 -graph_diversity(marvel_friends, "Rich") +network_diversity(marvel_friends, "Rich") #> [1] 0.188 -graph_diversity(marvel_friends, "Intellect") +network_diversity(marvel_friends, "Intellect") #> [1] 0.465 ``` @@ -120,9 +118,9 @@ or equally intellectually diverse across gender.^[Note that this works for calcu ```r -graph_diversity(marvel_friends, "Gender", "PowerOrigin") +network_diversity(marvel_friends, "Gender", "PowerOrigin") #> [1] 0.000 0.000 0.463 0.375 -graph_diversity(marvel_friends, "Intellect", "Gender") +network_diversity(marvel_friends, "Intellect", "Gender") #> [1] 0.480 0.459 ``` @@ -142,7 +140,7 @@ autographr(marvel_friends, node_color = "Gender") ``` -![plot of chunk blaugroups](teaching/blaugroups-1.png) +![](teaching/blaugroups-1.png) ```r autographr(marvel_friends, @@ -150,7 +148,7 @@ autographr(marvel_friends, node_size = "Intellect") ``` -![plot of chunk blaugroups](teaching/blaugroups-2.png) +![](teaching/blaugroups-2.png) Ok, this tells us about how (un)even the distribution of these variables is in this network, but it doesn't necessarily tell us whether within this network there is homophily/heterophily. @@ -169,11 +167,11 @@ As such, an EI index of -1 suggests perfect homophily, whereas an EI index of +1 ```r -(obs.gender <- graph_homophily(marvel_friends, "Gender")) +(obs.gender <- network_homophily(marvel_friends, "Gender")) #> [1] -0.196 -(obs.powers <- graph_homophily(marvel_friends, "PowerOrigin")) +(obs.powers <- network_homophily(marvel_friends, "PowerOrigin")) #> [1] -0.00935 -(obs.attract <- graph_homophily(marvel_friends, "Attractive")) +(obs.attract <- network_homophily(marvel_friends, "Attractive")) #> [1] -0.645 ``` @@ -204,20 +202,20 @@ such as `test_random()`: ```r rand.gender <- test_random(marvel_friends, - graph_homophily, attribute = "Gender", + network_homophily, attribute = "Gender", times = 20) rand.power <- test_random(marvel_friends, - graph_homophily, attribute = "PowerOrigin", + network_homophily, attribute = "PowerOrigin", times = 20) rand.attract <- test_random(marvel_friends, - graph_homophily, attribute = "Attractive", + network_homophily, attribute = "Attractive", times = 20) plot(rand.gender) / plot(rand.power) / plot(rand.attract) ``` -![plot of chunk rando](teaching/rando-1.png) +![](teaching/rando-1.png) The plots of these results use a dotted vertical line for 0 where this is in bounds, a red vertical line for the observed score, @@ -261,7 +259,7 @@ new <- autographr(generate_permutation(marvel_friends, with_attr = TRUE), old + new ``` -![plot of chunk perm](teaching/perm-1.png) +![](teaching/perm-1.png) This single permutation suggests there might otherwise be some more even mixing of these attributes, but it is just a single permutation. @@ -271,10 +269,10 @@ just as we did with random graphs. ```r perm.gender <- test_permutation(marvel_friends, - graph_homophily, attribute = "Gender", + network_homophily, attribute = "Gender", times = 1000) perm.power <- test_permutation(marvel_friends, - graph_homophily, attribute = "PowerOrigin", + network_homophily, attribute = "PowerOrigin", times = 1000) ``` @@ -287,7 +285,7 @@ for gender that we did, but the lack of power origin heterophily is surprising. (plot(perm.gender) | plot(perm.power)) ``` -![plot of chunk cugqap](teaching/cugqap-1.png) +![](teaching/cugqap-1.png) Note how the distributions are generally wider when permuting the observed network than creating a random distribution (be mindful of the scale of the _x_-axis). @@ -310,14 +308,14 @@ ison_networkers #> # A directed simple graph with 1 component #> # #> # Node Data: 32 × 3 (active) -#> name Discipline Citatio… -#> -#> 1 LIN FREEMAN Sociology 19 -#> 2 DOUG WHITE Anthropology 3 -#> 3 EV ROGERS Other 170 -#> 4 RICHARD ALBA Sociology 23 -#> 5 PHIPPS ARABIE Other 16 -#> 6 CAROL BARNER-BARRY Other 6 +#> name Discipline Citations +#> +#> 1 LIN FREEMAN Sociology 19 +#> 2 DOUG WHITE Anthropology 3 +#> 3 EV ROGERS Other 170 +#> 4 RICHARD ALBA Sociology 23 +#> 5 PHIPPS ARABIE Other 16 +#> 6 CAROL BARNER-BARRY Other 6 #> # … with 26 more rows #> # #> # Edge Data: 440 × 3 @@ -331,7 +329,7 @@ autographr(ison_networkers, node_color = "Discipline") ``` -![plot of chunk intro-eies](teaching/intro-eies-1.png) +![](teaching/intro-eies-1.png) Let's use both the continuous `Citations` and the categorical `Discipline` variables and come up with a couple of key hypotheses: @@ -357,30 +355,28 @@ facilitate the quick interpretation of these results. ```r tidy(model1) #> # A tibble: 7 × 4 -#> term estimate stati…¹ p.value -#> -#> 1 (intercept) 1.72 0.194 0.91 -#> 2 alter Citations -0.0326 -0.588 0.58 -#> 3 sim Citations 24.4 2.86 0.235 -#> 4 alter Discipli… -16.8 -3.07 0.29 -#> 5 alter Discipli… -10.6 -2.31 0.475 -#> 6 alter Discipli… -7.37 -1.90 0.575 -#> 7 same Discipline 3.90 1.23 0.395 -#> # … with abbreviated variable name -#> # ¹​statistic +#> term estimate stati…¹ p.value +#> +#> 1 (intercept) 1.72 0.194 0.94 +#> 2 alter Citations -0.0326 -0.588 0.625 +#> 3 sim Citations 24.4 2.86 0.215 +#> 4 alter Discipline Mathemat… -16.8 -3.07 0.265 +#> 5 alter Discipline Other -10.6 -2.31 0.475 +#> 6 alter Discipline Sociology -7.37 -1.90 0.495 +#> 7 same Discipline 3.90 1.23 0.41 +#> # … with abbreviated variable name ¹​statistic glance(model1) #> # A tibble: 1 × 8 -#> r.squared adj.r.…¹ sigma stati…² p.value -#> -#> 1 0.0334 0.0275 43.1 5.67 8.33e-6 -#> # … with 3 more variables: df , -#> # df.residual , nobs , and -#> # abbreviated variable names -#> # ¹​adj.r.squared, ²​statistic +#> r.squ…¹ adj.r…² sigma stati…³ p.value df df.re…⁴ +#> +#> 1 0.0334 0.0275 43.1 5.67 8.33e-6 6 985 +#> # … with 1 more variable: nobs , and +#> # abbreviated variable names ¹​r.squared, +#> # ²​adj.r.squared, ³​statistic, ⁴​df.residual plot(model1) ``` -![plot of chunk qap-interp](teaching/qap-interp-1.png) +![](teaching/qap-interp-1.png) This voilin plot presents the distribution of coefficients from permutations of the network, with the fitted coefficient from the data as a red dot. diff --git a/vignettes/p7linearmodel.Rmd.orig b/vignettes/p7linearmodel.Rmd.orig index abe446d7..d868dc12 100644 --- a/vignettes/p7linearmodel.Rmd.orig +++ b/vignettes/p7linearmodel.Rmd.orig @@ -13,6 +13,7 @@ vignette: > knitr::opts_chunk$set( collapse = TRUE, comment = "#>", + fig.cap = "", fig.path = "teaching/" ) ``` @@ -73,11 +74,11 @@ while a perfectly heterogeneous group (with members spread evenly over the maxim would receive a score of 1. ```{r blau} -graph_diversity(marvel_friends, "Gender") -graph_diversity(marvel_friends, "PowerOrigin") -graph_diversity(marvel_friends, "Attractive") -graph_diversity(marvel_friends, "Rich") -graph_diversity(marvel_friends, "Intellect") +network_diversity(marvel_friends, "Gender") +network_diversity(marvel_friends, "PowerOrigin") +network_diversity(marvel_friends, "Attractive") +network_diversity(marvel_friends, "Rich") +network_diversity(marvel_friends, "Intellect") ``` Looks like there is more diversity in terms of where these characters got @@ -90,8 +91,8 @@ are equally gender diverse across their (power) origin stories, or equally intellectually diverse across gender.^[Note that this works for calculated categorical variables too, such as cluster/group assignment from community detection or equivalence classes.] ```{r crossref} -graph_diversity(marvel_friends, "Gender", "PowerOrigin") -graph_diversity(marvel_friends, "Intellect", "Gender") +network_diversity(marvel_friends, "Gender", "PowerOrigin") +network_diversity(marvel_friends, "Intellect", "Gender") ``` Note that the length of the vector returned as a result @@ -128,9 +129,9 @@ and $I$ is the number of ties present within a variable's categories (i.e. inter As such, an EI index of -1 suggests perfect homophily, whereas an EI index of +1 suggests perfect heterophily. ```{r ei} -(obs.gender <- graph_homophily(marvel_friends, "Gender")) -(obs.powers <- graph_homophily(marvel_friends, "PowerOrigin")) -(obs.attract <- graph_homophily(marvel_friends, "Attractive")) +(obs.gender <- network_homophily(marvel_friends, "Gender")) +(obs.powers <- network_homophily(marvel_friends, "PowerOrigin")) +(obs.attract <- network_homophily(marvel_friends, "Attractive")) ``` Looks like there might be some gender homophily present, @@ -159,13 +160,13 @@ such as `test_random()`: ```{r rando} rand.gender <- test_random(marvel_friends, - graph_homophily, attribute = "Gender", + network_homophily, attribute = "Gender", times = 20) rand.power <- test_random(marvel_friends, - graph_homophily, attribute = "PowerOrigin", + network_homophily, attribute = "PowerOrigin", times = 20) rand.attract <- test_random(marvel_friends, - graph_homophily, attribute = "Attractive", + network_homophily, attribute = "Attractive", times = 20) plot(rand.gender) / plot(rand.power) / @@ -220,10 +221,10 @@ just as we did with random graphs. ```{r test_permute} perm.gender <- test_permutation(marvel_friends, - graph_homophily, attribute = "Gender", + network_homophily, attribute = "Gender", times = 1000) perm.power <- test_permutation(marvel_friends, - graph_homophily, attribute = "PowerOrigin", + network_homophily, attribute = "PowerOrigin", times = 1000) ``` diff --git a/vignettes/teaching/addingnames-1.png b/vignettes/teaching/addingnames-1.png index aae91ddd..7a95f155 100644 Binary files a/vignettes/teaching/addingnames-1.png and b/vignettes/teaching/addingnames-1.png differ diff --git a/vignettes/teaching/blaugroups-1.png b/vignettes/teaching/blaugroups-1.png index 7a7fb019..22415a0c 100644 Binary files a/vignettes/teaching/blaugroups-1.png and b/vignettes/teaching/blaugroups-1.png differ diff --git a/vignettes/teaching/blaugroups-2.png b/vignettes/teaching/blaugroups-2.png index c352e307..54ddbc81 100644 Binary files a/vignettes/teaching/blaugroups-2.png and b/vignettes/teaching/blaugroups-2.png differ diff --git a/vignettes/teaching/constraintplot-1.png b/vignettes/teaching/constraintplot-1.png index 885b8ebf..267fb16c 100644 Binary files a/vignettes/teaching/constraintplot-1.png and b/vignettes/teaching/constraintplot-1.png differ diff --git a/vignettes/teaching/cugqap-1.png b/vignettes/teaching/cugqap-1.png index f9c88734..85759443 100644 Binary files a/vignettes/teaching/cugqap-1.png and b/vignettes/teaching/cugqap-1.png differ diff --git a/vignettes/teaching/find-se-1.png b/vignettes/teaching/find-se-1.png index 76679616..9943c4b7 100644 Binary files a/vignettes/teaching/find-se-1.png and b/vignettes/teaching/find-se-1.png differ diff --git a/vignettes/teaching/ggid-1.png b/vignettes/teaching/ggid-1.png index 51318dde..a7a63b85 100644 Binary files a/vignettes/teaching/ggid-1.png and b/vignettes/teaching/ggid-1.png differ diff --git a/vignettes/teaching/ggid-2.png b/vignettes/teaching/ggid-2.png index 0970101b..eadb9836 100644 Binary files a/vignettes/teaching/ggid-2.png and b/vignettes/teaching/ggid-2.png differ diff --git a/vignettes/teaching/ggid-3.png b/vignettes/teaching/ggid-3.png index bca635bd..b329dcea 100644 Binary files a/vignettes/teaching/ggid-3.png and b/vignettes/teaching/ggid-3.png differ diff --git a/vignettes/teaching/ggid-4.png b/vignettes/teaching/ggid-4.png index 4441ea3b..87d74ed4 100644 Binary files a/vignettes/teaching/ggid-4.png and b/vignettes/teaching/ggid-4.png differ diff --git a/vignettes/teaching/ggrapheg-1.png b/vignettes/teaching/ggrapheg-1.png new file mode 100644 index 00000000..2f801a15 Binary files /dev/null and b/vignettes/teaching/ggrapheg-1.png differ diff --git a/vignettes/teaching/intro-eies-1.png b/vignettes/teaching/intro-eies-1.png index 25d2dd41..9e4a778c 100644 Binary files a/vignettes/teaching/intro-eies-1.png and b/vignettes/teaching/intro-eies-1.png differ diff --git a/vignettes/teaching/layoutseg-1.png b/vignettes/teaching/layoutseg-1.png new file mode 100644 index 00000000..0249d1d7 Binary files /dev/null and b/vignettes/teaching/layoutseg-1.png differ diff --git a/vignettes/teaching/migrapheg-1.png b/vignettes/teaching/migrapheg-1.png new file mode 100644 index 00000000..a897ef07 Binary files /dev/null and b/vignettes/teaching/migrapheg-1.png differ diff --git a/vignettes/teaching/migraphexample2-1.png b/vignettes/teaching/migraphexample2-1.png new file mode 100644 index 00000000..c42502dd Binary files /dev/null and b/vignettes/teaching/migraphexample2-1.png differ diff --git a/vignettes/teaching/multiplot-1.png b/vignettes/teaching/multiplot-1.png index fcab06a6..3a34a156 100644 Binary files a/vignettes/teaching/multiplot-1.png and b/vignettes/teaching/multiplot-1.png differ diff --git a/vignettes/teaching/patchwork-1.png b/vignettes/teaching/patchwork-1.png new file mode 100644 index 00000000..3ad2f7c7 Binary files /dev/null and b/vignettes/teaching/patchwork-1.png differ diff --git a/vignettes/teaching/patchwork-2.png b/vignettes/teaching/patchwork-2.png new file mode 100644 index 00000000..147b0ce3 Binary files /dev/null and b/vignettes/teaching/patchwork-2.png differ diff --git a/vignettes/teaching/perm-1.png b/vignettes/teaching/perm-1.png index adaf9440..d17504d3 100644 Binary files a/vignettes/teaching/perm-1.png and b/vignettes/teaching/perm-1.png differ diff --git a/vignettes/teaching/qap-interp-1.png b/vignettes/teaching/qap-interp-1.png index 049371a0..c7f38167 100644 Binary files a/vignettes/teaching/qap-interp-1.png and b/vignettes/teaching/qap-interp-1.png differ diff --git a/vignettes/teaching/rando-1.png b/vignettes/teaching/rando-1.png index 3bd8ee7e..61f9a527 100644 Binary files a/vignettes/teaching/rando-1.png and b/vignettes/teaching/rando-1.png differ diff --git a/vignettes/teaching/separatingnets-1.png b/vignettes/teaching/separatingnets-1.png index a0d5e049..b343be33 100644 Binary files a/vignettes/teaching/separatingnets-1.png and b/vignettes/teaching/separatingnets-1.png differ diff --git a/vignettes/teaching/strplot-1.png b/vignettes/teaching/strplot-1.png index ee5aed70..3a5439e5 100644 Binary files a/vignettes/teaching/strplot-1.png and b/vignettes/teaching/strplot-1.png differ diff --git a/vignettes/teaching/structblock-1.png b/vignettes/teaching/structblock-1.png index 136c23d8..b7bdf953 100644 Binary files a/vignettes/teaching/structblock-1.png and b/vignettes/teaching/structblock-1.png differ diff --git a/vignettes/teaching/unnamed-chunk-2-1.png b/vignettes/teaching/unnamed-chunk-2-1.png index 4f241820..1d697bb7 100644 Binary files a/vignettes/teaching/unnamed-chunk-2-1.png and b/vignettes/teaching/unnamed-chunk-2-1.png differ