get_transition: Compute a transition matrix from an adjacency matrix.

Description Usage Arguments Value Examples

View source: R/transition_matrix.R

Description

This method take an adjacency matrix (dense or sparse), and returns the corresponding transition matrix in the same format. If the optional argument 'directed' is specified to be FALSE, then before computing the transition matrix the adjacency matrix is forced be symmetric.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
get_transition(adj, directed = NULL, ...)

## S3 method for class 'matrix'
get_transition(adj, directed = NULL, ...)

## S3 method for class 'dgTMatrix'
get_transition(adj, directed = NULL, ...)

## S3 method for class 'dgCMatrix'
get_transition(adj, directed = NULL, ...)

## S3 method for class 'sparseMatrix'
get_transition(adj, directed = NULL, ...)

## Default S3 method:
get_transition(adj, directed = NULL, ...)

Arguments

adj

adjacency matrix, either dense or sparse

directed

boolean, optional argument specifying if the matrix refers to a directed graph.

...

additional parameters to and from the main method. Currently not used.

Value

A transition matrix in the same format of 'adj'.

Examples

1
2
3
4
5
el <- data.frame(from= c('a','b','b','c','d','d'),
                to  = c('b','c','d','a','b','a'),
                attr= c( 12, 6, 12 , 6 , 6 , 6 ))
adj <- el2adj(el)
t_mat <- get_transition(adj)

gi0na/adjConvertR documentation built on Jan. 7, 2022, 4:48 a.m.