hist(links$weight) mean(links$weight) sd(links$weight)
delete.edges(net, edges)
: cut.off <- mean(links$weight) net.sp <- delete.edges(net, E(net)[weight<cut.off]) l <- layout.fruchterman.reingold(net.sp, repulserad=vcount(net)^2.1) plot(net.sp, layout=l)
E(net)$width <- 1.5 plot(net, edge.color=c("dark red", "slategrey")[(E(net)$type=="hyperlink")+1], vertex.color="gray40", layout=layout.circle)
net.m <- net - E(net)[E(net)$type=="hyperlink"] # net.h <- net - E(net)[E(net)$type=="mention"] par(mfrow=c(1,2)) plot(net.h, vertex.color="orange", main="Tie: Hyperlink") # : plot(net.m, vertex.color="lightsteelblue2", main="Tie: Mention") # :
l <- layout.fruchterman.reingold(net) plot(net.h, vertex.color="orange", layout=l, main="Tie: Hyperlink") plot(net.m, vertex.color="lightsteelblue2", layout=l, main="Tie: Mention")
dev.off()
V(net)$community <- optimal.community(net)$membership colrs <- adjustcolor( c("gray50", "tomato", "gold", "yellowgreen"), alpha=.6) plot(net, vertex.color=colrs[V(net)$community])
shortest.paths
function (as the name shows) returns the matrix of shortest paths between vertices in the network. dist.from.NYT <- shortest.paths(net, algorithm="unweighted")[1,] oranges <- colorRampPalette(c("dark red", "gold")) col <- oranges(max(dist.from.NYT)+1)[dist.from.NYT+1] plot(net, vertex.color=col, vertex.label=dist.from.NYT, edge.arrow.size=.6, vertex.label.color="white")
neighbors
function finds all vertices in one step from the center feature. A similar function that finds all the edges for a node is called incident
. col <- rep("grey40", vcount(net)) col[V(net)$media=="Wall Street Journal"] <- "#ff5100" neigh.nodes <- neighbors(net, V(net)[media=="Wall Street Journal"], mode="out") col[neigh.nodes] <- "#ff9d00" plot(net, vertex.color=col)
plot(net, mark.groups=c(1,4,5,8), mark.col="#C5E5E7", mark.border=NA)
# : plot(net, mark.groups=list(c(1,4,5,8), c(15:17)), mark.col=c("#C5E5E7","#ECD89A"), mark.border=NA)
news.path <- get.shortest.paths(net, V(net)[media=="MSNBC"], V(net)[media=="New York Post"], mode="all", output="both") # : ecol <- rep("gray80", ecount(net)) ecol[unlist(news.path$epath)] <- "orange" # : ew <- rep(2, ecount(net)) ew[unlist(news.path$epath)] <- 4 # : vcol <- rep("gray40", vcount(net)) vcol[unlist(news.path$vpath)] <- "gold" plot(net, vertex.color=vcol, edge.color=ecol, edge.width=ew, edge.arrow.mode=0)
Source: https://habr.com/ru/post/266285/
All Articles