triad_census_attr: triad census with node attributes

View source: R/triad_census_attr.R

triad_census_attrR Documentation

triad census with node attributes

Description

triad census with node attributes

Usage

triad_census_attr(g, vattr)

Arguments

g

igraph object. should be a directed graph

vattr

name of vertex attribute to be used

Details

The node attribute should be integers from 1 to max(attr). The output is a named vector where the names are of the form Txxx-abc, where xxx corresponds to the standard triad census notation and "abc" are the attributes of the involved nodes. If there are more than nine attribute values, the attributes are separated by dots (Txxx-a.b.c). For cyclic triads (030C) with three distinct attributes, the two orientations are counted separately: "abc" if the edges point from the smallest to the middle attribute value, "cba" otherwise. Multiple edges and loops are ignored.

The implemented algorithm is comparable to the algorithm in Lienert et al.

Value

triad census with node attributes

Author(s)

David Schoch

References

Lienert, J., Koehly, L., Reed-Tsochas, F., & Marcum, C. S. (2019). An efficient counting method for the colored triad census. Social Networks, 58, 136-142.

Examples

library(igraph)
set.seed(112)
g <- sample_gnp(20, p = 0.3, directed = TRUE)
# add a vertex attribute
V(g)$type <- rep(1:2, each = 10)
triad_census_attr(g, "type")

netUtils documentation built on Sept. 30, 2026, 5:10 p.m.