nwsubset

Subset the nodes of a network

Syntax

nwsubset 
[netname]
[if]
[,
name(newnetname)
replace]
   
name(newnetname) name of the new network
replace replace existing network

Description

nwsubset simply subsets an existing network netname. By default, the subset network is called netname_sub. It consists of all the nodes of the original network netname for which the if condition is true. When no if condition is specified, the command simply generates a duplicate.

For example, this generates a new network from the flomarriage network that consists of only the nodes with wealth > 50.

  • . nwwebuse florentine, nwclear
  • . nwsubset flomarriage if wealth > 50

By default, this generates a new network called flomarriage_sub. Notice that something similar could be achieved with nwgen:

  • . nwgen flo_sub = flomarriage if wealth > 50

However, the last command does not copy the node labels of network flomarriage. This is because the if condition in nwgen applies to a whole network expression. Because network expressions can be very complicated, no labels are copied.

Supported network types

Binary: yes. Directed: yes. Weighted: yes, tie values are preserved in the extracted subset. Signed: yes, values including negative are preserved. Two-mode: yes - the flag, the modes and the level labels are kept for the nodes that remain.

See also


nwcommands version 3.17.6, 9 November 2026 (check your installed version)


Back to top

nwcommands is free software under the GNU General Public License, version 3, as are the model packages nwsaom, nwergm, nwdynam and nwrem. Citing and licenses · Get help · GitHub. Issues with the core go to the nwcommands repository; issues with a model package go to that package's own repository.

This site uses Just the Docs, a documentation theme for Jekyll.