xConverter | R Documentation

## Function to convert an object between graph classes

### Description

`xConverter` is supposed to convert an object between classes 'dgCMatrix' and 'igraph'.

### Usage

    xConverter(obj, from = c("dgCMatrix", "igraph"), to = c("igraph",
    "dgCMatrix"), verbose = TRUE)

### Arguments

`obj` | an object of class "dgCMatrix" or "igraph"
`from` | a character specifying the class converted from. It can be one of "dgCMatrix" and "igraph"
`to` | a character specifying the class converted to. It can be one of "dgCMatrix" and "igraph"
`verbose` | logical to indicate whether the messages will be displayed in the screen. By default, it sets to true for display

### Value

an object of class "dgCMatrix" or "igraph"

### Note

Conversion is also supported between classes 'dgCMatrix' and 'igraph'

### See Also

`xRDataLoader`

### Examples

    # generate a ring graph
    g <- make_ring(10, directed=TRUE)

    # convert the object from 'igraph' to 'dgCMatrix' class
    xConverter(g, from='igraph', to='dgCMatrix')

    ## Not run:
    # Conversion between 'dgCMatrix' and 'igraph'
    # ig.EF (an object of class "igraph" storing as a directed graph)
    g <- xRDataLoader('ig.EF')
    g

    # convert the object from 'igraph' to 'dgCMatrix' class
    s <- xConverter(g, from='igraph', to='dgCMatrix')
    s[1:10,1:10]

    # convert the object from 'dgCMatrix' to 'igraph' class
    ig <- xConverter(s, from="dgCMatrix", to="igraph")
    ig

    ## End(Not run)