clust2Mat {GraphAT} | R Documentation

## Function to compute adjacency matrix of cluster graph given a vector of cluster memberships

### Description

Given a list of cluster memberships, this function computes the adjacency matrix for the associated cluster graph. The adjacency matrix is a matrix whose rows and columns are the nodes of the cluster graph and whose entries are 0's or 1's. A 1 entry indicates that the corresponding nodes are connected, and a 0 indocates that they are not.

### Usage

    clust2Mat(memb)

### Arguments

`memb` | A numeric vector, with each entry representing a node, the entry's value being the number of the cluster to which that node belongs.

### Details

Given a vector of cluster membership numbers, where the number of entries is the number of nodes n, the function computes an nxn ``adjacency matrix'' for the corresponding cluster graph. The cluster graph is the graph in which two nodes are connected by an edge if and only if they are members of the same cluster. The adjacency matrix for the graph has rows and columns representing the nodes, in the same order as the input vector. The (i,j) entry is 1 if and only if node i and node j are in the same cluster. Otherwise, the entry is 0. By convention, diagonal entries are 0.

### Value

An nxn adjacency matrix for the cluster graph, where n=length of cluster membership input vector memb.

### Author(s)

Tom LaFramboise tlaframb@hsph.harvard.edu

### See Also

`makeClustM`

### Examples

    memberships<-c(1,2,3,1,2,3,1,2,3,4)
    clust2Mat(memberships)

[Package GraphAT version 1.12.0 Index]