EduStructure
Структура отношений на проекте edu
Новая версия
Старая версия
lt2 <- data.frame(User = paste("A",hist[,1],sep=":" ) , Page = paste("O",hist[,2],sep=":"), Action = hist[,3] ) # Agent vs Object lt2.network <- graph.data.frame(lt2,directed=T) ; E(lt2.network)$color <- ifelse(E(lt2.network)$Action =='createidea', "red", "green") lt2.network <- simplify(lt2.network) V(lt2.network)$color <-ifelse (substring(V(lt2.network)$name, 1, 1) == "A",'red','blue') V(lt2.network)$shape <-ifelse (substring(V(lt2.network)$name, 1, 1) == "A",'circle','square') set.seed(42) plot(lt2.network, edge.arrow.size=.2,vertex.label=NA, vertex.size=4, layout=layout.fruchterman.reingold) # Test plot(lt2.network, edge.arrow.size=.2,vertex.label=NA, vertex.size=1, layout=layout.kamada.kawai) # Test l <- delete.vertices(lt2.network,V(lt2.network)[degree(lt2.network)<=1]) plot(l, edge.arrow.size=.2,vertex.label=NA, vertex.size=1, layout=layout.kamada.kawai) # Test plot(l, edge.arrow.size=.2,vertex.label=NA, vertex.size=3, layout=layout.fruchterman.reingold)# Test
plot(l, edge.arrow.size=.2,vertex.label=NA, vertex.size=2, layout=layout.kamada.kawai)
- Test
deg <- degree(lt2.network, mode="all")
- V(lt2.network)$label <-ifelse (substring(V(lt2.network)$name, 1, 1) == "U" & deg > 50, V(lt2.network)$name, NA)
plot(lt2.network, edge.arrow.size=.4,vertex.size=deg/10, layout=layout.kamada.kawai)
- From bigraph to monograph
g2 <- lt2 ; A <- spMatrix(nrow=length(unique(g2$User)),
ncol=length(unique(g2$Page)), i = as.numeric(factor(g2$User)), j = as.numeric(factor(g2$Page)), x = rep(1, length(as.numeric(g2$User))) )
row.names(A) <- levels(factor(g2$User)) colnames(A) <- levels(factor(g2$Page)) Arow <- A %*% t(A) ## Persons Acol <- t(A) %*% A ## Groups - Objects gm <- graph_from_adjacency_matrix(Arow, weighted=T, mode = "undirected") gm <- graph_from_adjacency_matrix(Acol, weighted=T, mode = "undirected") gm <- simplify(gm) E(gm)$label = NA V(gm)$label = NA set.seed(10)
- deg <- degree(gm, mode="all")
plot(gm, edge.arrow.size=.4, vertex.size=5, edge.width = 1, vertex.color="red", layout=layout.fruchterman.reingold) plot(gm, edge.arrow.size=.4, vertex.size=5, vertex.shape='square', vertex.color="blue", edge.width = 1, layout=layout.fruchterman.reingold)
- Metrics
gm graph.density(gm) # Density (No of edges / possible edges) clusters(gm)$no ## # Число островов - не связанных между собой компонентов diameter(gm) ## Diameter of the graph measure the longest distance between any two nodes
- clusters(gm, mode="weak") # Connected Component
transitivity(gm, type="global") # Global cluster coefficient centralization.betweenness (gm, directed = FALSE, nobigint = TRUE, normalized = TRUE) largest.cliques(gm)
Связи между проектами