#Load the igraph library
library(igraph)
## Warning: package 'igraph' was built under R version 3.4.2
##
## Attaching package: 'igraph'
## The following objects are masked from 'package:stats':
##
## decompose, spectrum
## The following object is masked from 'package:base':
##
## union
#Read the data with connection information
data <- read.csv("c:\\incident\\hostconn.csv",header=TRUE,row.names=1)
#Create matrix 0f data
adj<-as.matrix(data)
#Create Adjacency Matrix
graph_adj<-graph.adjacency(adj,mode="undirected",diag=FALSE)
#Traverse using reingold tilford algorithm and plot the traversal
plot(graph_adj,layout=layout.reingold.tilford(graph_adj,root="X1"))

#Traverse using Breadth First Search algorithm and display the degree of seperation from root of host "X1"
temp <-graph.bfs(graph_adj, root="X1", neimode='all', order=TRUE,dist= TRUE)
temp$dist
## X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13
## 0 1 1 1 1 1 1 1 1 2 2 2 2