The complete R script
Here is the complete R script that we have used to demonstrate product network analysis:
library(igraph, quietly = TRUE) ## Creating a simple graph simple.graph <- graph_from_literal(A-B, B-C, C-D, E-F, A-E, E-C) plot.igraph(simple.graph) ## Graph properties E(simple.graph) # Edges V(simple.graph) # Vertices ## Graph attributes V(simple.graph)$name <- c('alice', 'bob','charlie','david', 'eli','francis') simple.graph <- set_vertex_attr(simple.graph ,"age", value = c('11', '11','15','9', '8','11')) plot.igraph(simple.graph) V(simple.graph)$color <- ifelse(V(simple.graph)$age == '11', "blue","green") plot.igraph(simple.graph) # Structural properties degree(simple.graph) # degree of nodes E(simple.graph)$weight <- c(10,20,35,15,25,35) strength(simple.graph) # strength of nodes get.adjacency(simple.graph) # adjacency matrix # Delete edges and nodes simple.graph <- delete.edges(simple.graph, "alice|bob" ) simple.graph <- delete.vertices(simple.graph...