nwnclan

Maximal n-clan enumeration

Syntax

nwnclan
[netlist]
[,
n(int)
gen:erate(newvarname)
replace
minsize(int)
max:cliques(#)
maxt:ime(#)
count:only
nom:atrix
silent]
   
n(int) Maximum geodesic distance allowed between any two members; default = 2
gen:erate(newvarname) Required. Name of the Stata variable that stores each node’s largest maximal-n-clan membership size; with several networks the variables are numbered (newvarname1, newvarname2, …)
replace Replace existing variable
minsize(int) Smallest n-clan size to report; default = 3
max:cliques(#) Stop with an error when more than this many maximal n-cliques have to be examined while looking for n-clans; default = 1,000,000
maxt:ime(#) Stop with an error when the search has run for this many seconds without finishing; default = 60
count:only Only count the sets (and tabulate them by size) - nothing is stored, so the count is not limited by memory; gen:erate(newvarname) is then not needed
nom:atrix Do not build the sets-by-nodes matrix; the gen:erate(newvarname) variable and the count are still returned
silent Suppress display of results

Description

nwnclan enumerates every maximal n-clan (Mokken 1979) in the network(s) in netlist - an n-clique (see that command for the base concept and n(int)) that additionally requires every pair of its own members to be reachable from one another while staying inside the group, within n(int) steps. An ordinary n-clique only guarantees each pair’s shortest path in the whole network is within n(int) - that path may run through a node that is not itself one of the n-clique’s own members, a known limitation of the plain n-clique concept (Alba 1973). n-clans fix exactly that: every member must be able to reach every other member using only paths that never leave the group.

nwnclan works by first enumerating every maximal n-clique (the same computation nwnclique itself performs) and then keeping only the ones whose own induced subgraph - built from the original network, restricted to just that n-clique’s members - has every pair of members within n(int) steps of each other, using only ties between members. This matches the standard treatment of n-clans in the literature: a maximal n-clique that fails this check is simply not reported as a clan at all, rather than being replaced with some smaller, clan-qualifying subset of itself - a genuine, deliberate limitation of the concept, not a shortcut taken here. Every n-clan is therefore also an n-clique, but not every n-clique is an n-clan; on a network with no “shortcut” structure (e.g. a network where every node’s shortest paths to everyone else already stay within whatever locally-dense region it belongs to) the two coincide exactly.

Like n-cliques, n-clans genuinely overlap, so nwnclan follows nwnclique’s own output shape: a single per-node “largest maximal n-clan membership size” summary variable (gen:erate(newvarname), required), plus the complete overlapping structure in r(nclan_matrix) and r(nclans). minsize(int) defaults to 3, matching nwclique / nwnclique.

Network types

Directed: symmetrized automatically. Valued: tie values are ignored (every tie counts as present; the command prints a note). Two-mode: same as for the bipartite graph read as a one-mode network. Signed: not checked. See nwnetworktypes.

Limits

Feasible sizes. The n-clans are the maximal n-cliques whose members are also within n steps of each other inside the group. The search does not list all maximal n-cliques first: it drops a branch as soon as a member already in the group is more than n steps from the newest member inside the group plus its remaining candidates (distances only grow in the subsets a clan below the branch can be), which leaves the clans found, and their order, unchanged. Measured in Stata/BE on a random network with 10 ties drawn per node and n(2): 100 / 300 / 1,000 nodes take 0.006 / 2.0 / 1.8 seconds (no / 114 / 5,777 clans); at 5,000 nodes there are 165,097 clans, found in 2.5 seconds with nomatrix, but the clans-by-nodes matrix (165,097 x 5,000) is too large to build, which the default says. Larger n() makes the “distance at most n” graph denser and the search much longer: at 1,000 nodes and n(3) the search took 197 seconds (and found no clan), so the default limit of 60 seconds stops it.

Guards. The command stops with r(484) and a message that names the option to raise when more than maxcliques() maximal n-cliques (default 1,000,000) had to be examined, when the result matrix would be too large to build (more than 50 million numbers; use nomatrix), or when the search has run for maxtime() seconds (default 60). countonly counts and tabulates the clans by size without storing them.

For all commands at network sizes of 1,000 to 100,000 nodes see the web page How large a network can I analyze?

Examples

. nwwebuse florentine, nwclear
. nwnclan flomarriage, generate(_nclannum)
. nwnclan flomarriage, n(3) generate(_nclannum) replace

Stored results

  • Scalars
  • r(nclans) — number of maximal n-clans found meeting minsize(int)
  • r(maxsize) — size of the largest set (with countonly or nomatrix)

  • Matrices
  • r(size_table) — (with countonly or nomatrix) sizes and the number of sets of each size
  • r(nclan_matrix) — n-clans-by-nodes 0/1 membership matrix, one row per maximal n-clan (not with countonly or nomatrix)

References

Mokken, R.J. (1979). Cliques, clubs and clans. Quality and Quantity 13(2), 161-173.

Alba, R.D. (1973). A graph-theoretic definition of a sociometric clique. Journal of Mathematical Sociology 3(1), 113-126.

Wasserman, S., Faust, K. (1994). Social Network Analysis: Methods and Applications. Cambridge University Press. (cliques and cohesive subgroups)

See also


nwcommands version 3.25.0, 14 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.