# NOT RUN {
# 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
##############
g <- make_graph("Zachary")
# from 'igraph' to "dtree","lol","json"
dtree <- xConverter(g, from='igraph', to='dtree')
lol <- xConverter(g, from='igraph', to='lol')
json <- xConverter(g, from='igraph', to='json')
# from "lol","json" to 'dtree'
dtree <- xConverter(lol, from='lol', to='dtree')
dtree <- xConverter(json, from='json', to='dtree')
# from 'dtree' to "igraph"
g <- xConverter(dtree, from='dtree', to='igraph')
# force 'igraph' to a tree
gtree <- xConverter(g, from='igraph', to='igraph_tree')
# }
Run the code above in your browser using DataLab