Set the random number generator to make the experiments repeatable

set.seed(1234)

library(igraph)
## 
## Attaching package: 'igraph'
## The following objects are masked from 'package:stats':
## 
##     decompose, spectrum
## The following object is masked from 'package:base':
## 
##     union
source("http://michael.hahsler.net/SMU/ScientificCompR/code/map.R")

Create a random graph

g <-erdos.renyi.game(30, 3/30)
summary(g)
## IGRAPH U--- 30 53 -- Erdos renyi (gnp) graph
## + attr: name (g/c), type (g/c), loops (g/l), p (g/n)

Plot graphs

plot(g)

Plot with an externally created layout

layout <-layout.fruchterman.reingold(g)
plot(g, layout=layout)

Interactive plot

tkplot(g)
## [1] 1

Inspect vertex degree and use the degree for vertex size

degree(g)
##  [1] 5 2 0 4 2 3 0 6 1 2 6 2 5 3 6 5 3 4 7 3 2 4 3 3 2 6 3 4 5 5
hist(degree(g))

plot(g, layout=layout, vertex.size=map(degree(g),c(1,20)))