R: List Triangles in a Graph

edges2triangles {spatstat.geom} | R Documentation

## List Triangles in a Graph

### Description

Given a list of edges between vertices, compile a list of all triangles formed by these edges.

### Usage

    edges2triangles(iedge, jedge, nvert=max(iedge, jedge), ...,
                    check=TRUE, friendly=rep(TRUE, nvert))

### Arguments

`iedge,jedge` | Integer vectors, of equal length, specifying the edges.
`nvert` | Number of vertices in the network.
`...` | Ignored
`check` | Logical. Whether to check validity of input data.
`friendly` | Optional. For advanced use. See Details.

### Details

This low level function finds all the triangles (cliques of size 3) in a finite graph with `nvert` vertices and with edges specified by `iedge, jedge`.

The interpretation of `iedge, jedge` is that each successive pair of entries specifies an edge in the graph. The kth edge joins vertex `iedge[k]` to vertex `jedge[k]`. Entries of `iedge` and `jedge` must be integers from 1 to `nvert`.

To improve efficiency in some applications, the optional argument `friendly` can be used. It should be a logical vector of length `nvert` specifying a labelling of the vertices, such that two vertices `j,k` which are not friendly (`friendly[j] = friendly[k] = FALSE`) are never connected by an edge.

### Value

A 3-column matrix of integers, in which each row represents a triangle.

### Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au

and Rolf Turner r.turner@auckland.ac.nz

### See Also

`edges2vees`

### Examples

     i <- c(1, 2, 5, 5, 1, 4, 2)
     j <- c(2, 3, 3, 1, 3, 2, 5)
     edges2triangles(i, j)

[Package spatstat.geom version 2.2-0 Index]