truss: Cluster by k-truss

Description Usage Arguments Value References Examples

Description

Compute the k-truss of an undirected graph.

Usage

1
truss(g, k, color_graph = FALSE)

Arguments

k

The level of support, requiring that every edge in subgraph is in at least (k-2) triangles (J. Cohen 2008). k must be at least 3.

color_graph

Logical to color the graph (perform truss membership).

graph

An undirected graph (must be igraph).

Value

A subgraph containing all k-trusses in the graph for a given level of support k.

References

J. Cohen. Trusses: Cohesive subgraphs for social network analysis, 2008.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
require(igraph)
set.seed(1)
g <- sample_gnm(6, 9)
E(g)$eid <- seq(ecount(g))
g_truss <- truss(g, k = 3)

# Plot original graph.
fixed_layout <- layout_with_lgl(g)
plot(g, layout = fixed_layout)  # original

# Plot graph with truss clustering.
E(g)$weight <- 1
E(g)$color <- "gray"
E(g)[E(g_truss)$eid]$color <- "blue"
E(g)[E(g_truss)$eid]$weight <- 3
plot(g, layout = fixed_layout, edge.width = E(g)$weight)  # with truss

alexperrone/truss documentation built on May 12, 2019, 2:31 a.m.