要回答一般問題,問題的第一部分,根據您試圖說明的內容,不同的可視化可能是有意義的。嘗試獲取網絡的一些基本描述:邊緣計數,密度,平均值。路徑距離,你已經知道你在看什麼樣的關係數據。正如LukeA指出的那樣,圖形可視化的洞察力非常依賴於手頭網絡數據的結構!
可視化並不一定是毫無意義的,但我會承認使用它們來證明一個教學點,而不是從實際得出任何分析結果,你應該首先考慮你想要在grpah中想象的東西。
當你決定你會得到所需要的洞察力,着色節點確實是一個關鍵的可視化工具: 至於問題的第二部分,在networkD3
你應該使用NodeGroup
參數顏色節點。在igraph中,當使用gplot()
進行繪圖時,您將矢量指定爲V(graph)$color
,並在sna-package中指定參數vertex.col
。
這裏是按距離從A中的igraph有色您的示例圖:
Source <- c("A", "A", "A", "A", "B", "B", "C", "C", "D")
Target <- c("B", "C", "D", "J", "E", "F", "G", "H", "I")
NetworkData <- data.frame(Source, Target)
# Visualize using igraph
library(igraph)
g <- graph_from_edgelist(as.matrix(NetworkData), directed = TRUE)
# Colour by distance from first node:
heatmap <- colorRampPalette(c("red", "yellow"))(100)
distance.from.first.node <- distances(g, V(g)[1])
V(g)$color <- heatmap[1+round(distance.from.first.node/(max(distance.from.first.node)/(length(heatmap)-1)))]
# Plot
plot.igraph(g)
我想不出任何點進行了密謀您所提供的數據,但如果你需要的話,那就是:
# Get the data you downloaded vvv(MAKE YOUR OWN PATH HERE)vvv
data <- read.csv(file="Downloads/Network.txt", sep="|")
# Remove your missing data
data <- data[data[,1]!="",]
data <- data[data[,2]!="",]
g2 <- graph_from_edgelist(as.matrix(data), directed = TRUE)
# Re-colour and plot:
distance.from.first.node <- distances(g2, V(g2)[1])
V(g2)$color <- heatmap[1+round(distance.from.first.node/(max(distance.from.first.node)/(length(heatmap)-1)))]
# Plot with smaller vertexes and no labels
plot.igraph(g2, vertex.size=4, vertex.label=NA)
你對這個數據集有何洞察力?我的意思是,從一眼看去,似乎只有從/到節點'435.9'的連接,因此它成爲「宇宙的中心」 – lukeA