nwsym

Symmetrize a network

Syntax

nwsym
[netname]
[,
mode(mode)
check
generate(newntename)
replace]
   
mode(mode) Logic for creating an undirected tie
check Check if network is symmetric (regardless of whether is declared as directed or undirected)
generate(newnetname) Save symmetrization as new network
replace Symmetrize in place (the default when neither replace nor generate() is given - this option exists to state that choice explicitly rather than to change behavior). Cannot be combined with generate()

Description

Symmetrizes a network and changes the meta-information of a network, i.e. it transforms a directed network in an undirected network. The logic for this transformation is defined by mode().

By default, an undirected tie is formed when there is either a tie from node i to node j or a tie from node j to node i; mode(max).

M_ij = max( M_ij, M_ji )

Alternatively, with mode(min) an undirected tie is only formed when there are both ties from node i to node j and a tie from node j to node i.

M_ij = min( M_ij, M_ji )

When not specified otherwise, the network netname is replaced with the symmetrized network (equivalently, replace can be given explicitly to state this). In case generate() is specified the new symmetrized network is saved as newnetname instead, and the original network is left untouched. replace and generate() are mutually exclusive.

Option check tests if the underlying adjacency matrix of the network is symmetric (but does not symmetrize the network). Notice that this is independent of any meta-information saved together with the network (see nwname). Hence, a network can be set as directed, but still be symmetric. In contrast, all undirected networks are by default also symmetric.

The logic for valued networks works in exactly the same way.

Examples

This loads the Glasgow data and symmetrizes the network glasgow1. After that the originally directed network has become undirected.

. nwwebuse glasgow, nwclear
. nwsym glasgow1

. nwsym glasgow1, check
--------------------------------------------------
   Network name:  glasgow1
   Directed: false
   Symmetric: true

This example only checks for symmetry, but does not change anything. Notice that by default nwrandom produces a directed network. However, a complete network (produced with prob(1)), where everybody is connected with everybody else, is also symmetric.

. nwrandom 10, prob(1)
. nwsym, check
--------------------------------------------------
   Network name:  network
   Directed: true
   Symmetric: true

Supported network types

Binary: yes. Directed: yes - this command’s entire purpose is converting a directed network to an undirected one (or checking whether it already is). Weighted: yes - mode() controls how the two directions’ tie values are combined (e.g. max/min/sum) when they differ. Signed: not checked. Two-mode: yes - the flag, the modes and the level labels are kept (a two-mode network is undirected already).

Stored results

  • Macros:
  • r(is_symmetric) “true” or “false”
  • r(name) name of the network

See also

  • nwsymmetrize (an exact alias for this command)

  • last certified : 28 Aug 2026


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.