Code Is Poetry

Life is Binary

#loading igraph for network analysis
require(igraph)

# creting trivial graph
g <- graph(c(1,2, 1,3, 2,3, 3,5),n=5)
plot(g)

# create random graph with 40 nodes each with 4 children
g <- graph.tree(40,4)
plot(g)

#diff layout for graph

#circle
plot(g, layout=layout.circle)

#fruchterman.reingold
plot(g, layout=layout.fruchterman.reingold)

#graphopt
plot(g, layout=layout.graphopt)

# interactive graph (graph node can me moved around with mouse select & drag)
tkplot(g, layout=layout.graphopt)

#3d graph layout with rgl package
rglplot(g,layout=layout.kamada.kawai)

#change color of nodes with plot function
plot(g, layout=layout.kamada.kawai, vertex.color="red")