Learn R Programming

NetworkDistance (version 0.3.6)

nd.hamming: Hamming Distance

Description

Hamming Distance is the count of discrepancy between two binary networks for each edge. Therefore, if used with non-binary networks, it might return a warning message and distorted results. It was originally designed to compare two strings of equal length, see Wikipedia page for more detailed introduction.

Usage

nd.hamming(A, out.dist = TRUE)

Value

a named list containing

D

an \((N\times N)\) matrix or dist object containing pairwise distance measures.

Arguments

A

a list of length \(N\) containing adjacency matrices.

out.dist

a logical; TRUE for computed distance matrix as a dist object.

References

hamming_error_1950NetworkDistance

Examples

Run this code
## load example data and extract only a few
data(graph20)
gr.small = graph20[c(1:5,11:15)]

## compute distance matrix
output = nd.hamming(gr.small, out.dist=FALSE)

## visualize
opar = par(no.readonly=TRUE)
par(pty="s")
image(output$D[,10:1], main="two group case", axes=FALSE, col=gray(0:32/32))
par(opar)

Run the code above in your browser using DataLab