前情回顧:
Gephi網(wǎng)絡(luò)圖極簡(jiǎn)教程
Network在單細(xì)胞轉(zhuǎn)錄組數(shù)據(jù)分析中的應(yīng)用
網(wǎng)絡(luò)數(shù)據(jù)統(tǒng)計(jì)分析筆記|| 為什么研究網(wǎng)絡(luò)
網(wǎng)絡(luò)數(shù)據(jù)統(tǒng)計(jì)分析筆記|| 操作網(wǎng)絡(luò)數(shù)據(jù)
以上兩章我們已經(jīng)圖的結(jié)構(gòu)有了零星地了解诊胞,雖然比較零散吧楞件。我們知道網(wǎng)絡(luò)圖作為一種數(shù)據(jù)結(jié)構(gòu),一個(gè)主要的功能就是可視化历造,即在圖中反應(yīng)點(diǎn)線關(guān)系∥弑冢可視化是一門藝術(shù)叠赐。本文我們介紹網(wǎng)絡(luò)圖可視化的基本概念和可視化圖的進(jìn)一步修飾。
我們?cè)谠鯓拥目臻g里來(lái)構(gòu)建網(wǎng)絡(luò)呢? 構(gòu)圖的元素就是點(diǎn)和線五鲫,可視化的過(guò)程就是給點(diǎn)找到合適的位置溺职,在特定的構(gòu)圖空間中如何布局繪圖元素可以近似為一個(gè)參數(shù)最優(yōu)化問(wèn)題。
圖的布局
圖數(shù)據(jù)的可視化(graph visualization)位喂,核心在布局(Layout)浪耘。以圖布局為核心的圖數(shù)據(jù)可視化的起點(diǎn),可以追溯到 1984年塑崖,在這一年七冲,Eades提出將圖數(shù)據(jù)的布局模擬為彈簧和鐵環(huán)的物理系統(tǒng)。
設(shè)置布局的目的是讓節(jié)點(diǎn)和邊可以根據(jù)某種策略進(jìn)行排布弃舒,從而使得圖形的可視化符合我們的要求癞埠。一般的話状原,布局的設(shè)置滿足四個(gè)原則:
- 節(jié)點(diǎn)能夠均勻的分布在窗口內(nèi)部。
- 避免邊的交叉和彎曲苗踪。
- 邊的長(zhǎng)度一致颠区。
- 整體的布局能夠滿足圖的特性展示。
在Gephi中通铲,基本的布局界面如下所示:
在Gephi中毕莱,一共給出了12個(gè)布局選項(xiàng),這些布局基本上可以分成兩種颅夺,一種是力引導(dǎo)的布局朋截,其能夠模仿物理世界的引力和斥力。力引導(dǎo)布局建立在物理學(xué)的基礎(chǔ)之后是之上吧黄。能夠?qū)D中的節(jié)點(diǎn)模擬成原子部服,通過(guò)模擬原子之間的力場(chǎng)來(lái)計(jì)算節(jié)點(diǎn)之間的關(guān)系。力布局的方法包括Force Altas拗慨、Force Atlas 2廓八、Fruchterman Reingold、OpenOrd赵抢、Yifan Hu剧蹂、Yifan Hu比例。
我們簡(jiǎn)要介紹幾種布局結(jié)構(gòu)烦却,注意啊宠叼,不是算法。
- 力導(dǎo)向布局算法也稱 FDP(Force-Directed Placement)算法是目前在圖布局算法上應(yīng)用最為廣泛的算法其爵,其在自然規(guī)則模型(彈簧或電荷力)的指導(dǎo)下冒冬,能以人類易理解的形式充分展現(xiàn)圖的整體結(jié)構(gòu),通用性強(qiáng)醋闭,在圖的布局算法中占據(jù)主導(dǎo)地位窄驹。根據(jù)力導(dǎo)向算法得到的布局結(jié)果朝卒,具有節(jié)點(diǎn)間相關(guān)的特性证逻,即布局過(guò)程取決于節(jié)點(diǎn)間的連接而非節(jié)點(diǎn)具有的屬性,這種方法的缺點(diǎn)是其對(duì)初始狀態(tài)十分敏感抗斤,且布局過(guò)程可能會(huì)陷入局部最優(yōu)解囚企,同時(shí)整個(gè)過(guò)程具有不確定性,不能確保每次得到相同的結(jié)果瑞眼。
該布局方法遵循兩個(gè)簡(jiǎn)單的原則:1龙宏、連接的點(diǎn)相互靠近。2伤疙、無(wú)連接的節(jié)點(diǎn)相互排斥银酗。
主要參數(shù)如下:
區(qū):定義圖形的幅度辆影,值越大圖越大,也越稀疏黍特。
重力: 定義重力值蛙讥、值越大、重力越強(qiáng)灭衷,節(jié)點(diǎn)越被中心吸引次慢。
速度:定義布局的速度,值越大布局速度越快翔曲、當(dāng)時(shí)越不精確迫像。
-
OpenOrd是一個(gè)面向大規(guī)模圖布局的開(kāi)源算法,來(lái)自論文OpenOrd:An Open-Source Toolbox for Large Graph Layout
-
Yifan Hu為胡一凡布局,適用于非常大的圖形瞳遍,特點(diǎn)是粗化圖形闻妓,減少計(jì)算量,運(yùn)行速度比較快掠械。 這是對(duì)于力引導(dǎo)布局的一種改進(jìn)纷闺。其在多層的力引導(dǎo)中引入了超節(jié)點(diǎn)的概念。在這個(gè)布局算法中份蝴,將一個(gè)節(jié)點(diǎn)與它遠(yuǎn)處的一簇之間的斥力當(dāng)做此節(jié)點(diǎn)之間的斥力來(lái)計(jì)算犁功,從而大大的減少了計(jì)算量,使得總的計(jì)算復(fù)雜度下降婚夫。
在igraph中有多少種布局算法呢浸卦?
1.1. igraph_layout_random — Places the vertices uniform randomly on a plane.
1.2. igraph_layout_circle — Places the vertices uniformly on a circle, in the order of vertex ids.
1.3. igraph_layout_star — Generate a star-like layout
1.4. igraph_layout_grid — Places the vertices on a regular grid on the plane.
1.5. igraph_layout_graphopt — Optimizes vertex layout via the graphopt algorithm.
1.6. igraph_layout_bipartite — Simple layout for bipartite graphs
1.7. The DrL layout generator
1.8. igraph_layout_fruchterman_reingold — Places the vertices on a plane according to the Fruchterman-Reingold algorithm.
1.9. igraph_layout_kamada_kawai — Places the vertices on a plane according the Kamada-Kawai algorithm.
1.10. igraph_layout_gem — The GEM layout algorithm, as described in Arne Frick, Andreas Ludwig,
1.11. igraph_layout_davidson_harel — Davidson-Harel layout algorithm
1.12. igraph_layout_mds — Place the vertices on a plane using multidimensional scaling.
1.13. igraph_layout_lgl — Force based layout algorithm for large graphs.
1.14. igraph_layout_reingold_tilford — Reingold-Tilford layout for tree graphs
1.15. igraph_layout_reingold_tilford_circular — Circular Reingold-Tilford layout for trees
1.16. igraph_layout_sugiyama — Sugiyama layout algorithm for layered directed acyclic graphs.
library(pacman)
grep('^layout_',p_functions(igraph),value = T)
[1] "layout_" "layout_as_bipartite" "layout_as_star" "layout_as_tree" "layout_components"
[6] "layout_in_circle" "layout_nicely" "layout_on_grid" "layout_on_sphere" "layout_randomly"
[11] "layout_with_dh" "layout_with_drl" "layout_with_fr" "layout_with_gem" "layout_with_graphopt"
[16] "layout_with_kk" "layout_with_lgl" "layout_with_mds" "layout_with_sugiyama"
圖的布局算法不是今天的主角,我們主要結(jié)合一些案例說(shuō)明布局的應(yīng)用案糙。我們會(huì)用一個(gè)555的網(wǎng)絡(luò)和一個(gè)博客網(wǎng)絡(luò)限嫌。
library(sand)
g.l <- make_lattice(c(5, 5, 5))
g.l
IGRAPH f14bc95 U--- 125 300 -- Lattice graph
+ attr: name (g/c), dimvector (g/n), nei (g/n), mutual (g/l), circular (g/l)
+ edges from f14bc95:
[1] 1-- 2 1-- 6 1--26 2-- 3 2-- 7 2--27 3-- 4 3-- 8 3--28 4-- 5 4-- 9 4--29 5--10 5--30 6-- 7 6--11
[17] 6--31 7-- 8 7--12 7--32 8-- 9 8--13 8--33 9--10 9--14 9--34 10--15 10--35 11--12 11--16 11--36 12--13
[33] 12--17 12--37 13--14 13--18 13--38 14--15 14--19 14--39 15--20 15--40 16--17 16--21 16--41 17--18 17--22 17--42
[49] 18--19 18--23 18--43 19--20 19--24 19--44 20--25 20--45 21--22 21--46 22--23 22--47 23--24 23--48 24--25 24--49
[65] 25--50 26--27 26--31 26--51 27--28 27--32 27--52 28--29 28--33 28--53 29--30 29--34 29--54 30--35 30--55 31--32
[81] 31--36 31--56 32--33 32--37 32--57 33--34 33--38 33--58 34--35 34--39 34--59 35--40 35--60 36--37 36--41 36--61
[97] 37--38 37--42 37--62 38--39 38--43 38--63 39--40 39--44 39--64 40--45 40--65 41--42 41--46 41--66 42--43 42--47
[113] 42--67 43--44 43--48 43--68 44--45 44--49 44--69 45--50 45--70 46--47 46--71 47--48 47--72 48--49 48--73 49--50
+ ... omitted several edges
data(aidsblog)
summary(aidsblog)
IGRAPH 3e85e7e D--- 146 187 --
aidsblog
IGRAPH 3e85e7e D--- 146 187 --
+ edges from 3e85e7e:
[1] 7-> 1 37-> 2 37-> 3 7-> 4 118-> 5 7-> 6 143-> 7 73-> 8 118-> 9 7-> 10 118-> 11 143-> 12 7-> 13
[14] 7-> 14 73-> 15 118-> 16 142-> 17 73-> 18 7-> 19 118-> 20 73-> 21 118-> 22 143-> 23 143-> 24 7-> 25 7-> 26
[27] 12-> 27 7-> 28 7-> 29 73-> 30 143-> 31 73-> 32 143-> 33 12-> 34 143-> 35 118-> 36 37-> 37 12-> 38 7-> 39
[40] 7-> 40 12-> 41 7-> 42 143-> 43 118-> 44 73-> 45 37-> 46 7-> 47 143-> 48 7-> 49 143-> 50 7-> 51 118-> 52
[53] 73-> 53 37-> 54 12-> 55 143-> 56 12-> 57 7-> 58 143-> 59 143-> 60 37-> 61 73-> 62 37-> 63 7-> 64 37-> 65
[66] 143-> 66 118-> 67 12-> 68 12-> 69 37-> 70 12-> 71 142-> 72 143-> 73 12-> 74 7-> 75 12-> 76 12-> 77 7-> 78
[79] 142-> 79 7-> 80 7-> 81 12-> 82 12-> 83 143-> 84 73-> 85 143-> 86 118-> 87 118-> 88 37-> 89 142-> 90 142-> 91
[92] 7-> 92 143-> 93 73-> 94 73-> 95 143-> 96 7-> 97 7-> 98 12-> 99 118->100 37->101 12->102 142->103 7->104
[105] 12->105 143->106 7->107 12->108 12->109 12->110 12->111 37->112 7->113 7->114 37->115 143->116 37->117
+ ... omitted several edges
可以看出博客網(wǎng)絡(luò)是有向的,從一個(gè)博客指向另一個(gè)的原因是其中包含了他的友情鏈接时捌。最簡(jiǎn)單的一種布局方法為環(huán)形布局怒医,所有的節(jié)點(diǎn)幾乎是等距地分布在一個(gè)圓形上。
V(aidsblog)$color <- colors()[1:(vcount(aidsblog))]
E(aidsblog)$color <- colors()[1:(ecount(aidsblog))]
# CHUNK 3
igraph_options(vertex.size=3, vertex.label=NA,
edge.arrow.size=0.5)
par(mfrow=c(1, 2))
plot(g.l, layout=layout_in_circle)
title("5x5x5 Lattice")
plot(aidsblog, layout=layout_in_circle)
應(yīng)用作用力模型的算法布局:The Fruchterman-Reingold layout algorithm
plot(g.l,layout=layout_with_fr)
title("5x5x5 Lattice")
plot(aidsblog,layout=layout_with_fr)
title("Blog Network")
想了解更多奢讨,可以?layout_with_fr
稚叹, 或者在控制臺(tái)輸入layout_with_fr 以查看源碼:
layout_with_fr
function (graph, coords = NULL, dim = 2, niter = 500, start.temp = sqrt(vcount(graph)),
grid = c("auto", "grid", "nogrid"), weights = NULL,
minx = NULL, maxx = NULL, miny = NULL, maxy = NULL, minz = NULL,
maxz = NULL, coolexp, maxdelta, area, repulserad, maxiter)
{
if (!is_igraph(graph)) {
stop("Not a graph object")
}
if (!is.null(coords)) {
coords <- as.matrix(structure(as.double(coords), dim = dim(coords)))
}
dim <- as.integer(dim)
if (dim != 2L && dim != 3L) {
stop("Dimension must be two or three")
}
if (!missing(niter) && !missing(maxiter)) {
stop("Both `niter' and `maxiter' are given, give only one of them")
}
if (!missing(maxiter))
niter <- maxiter
niter <- as.integer(niter)
start.temp <- as.numeric(start.temp)
grid <- igraph.match.arg(grid)
grid <- switch(grid, grid = 0L, nogrid = 1L, auto = 2L)
if (is.null(weights) && "weight" %in% edge_attr_names(graph)) {
weights <- E(graph)$weight
}
if (!is.null(weights) && any(!is.na(weights))) {
weights <- as.numeric(weights)
}
else {
weights <- NULL
}
if (!is.null(minx))
minx <- as.numeric(minx)
if (!is.null(maxx))
maxx <- as.numeric(maxx)
if (!is.null(miny))
miny <- as.numeric(miny)
if (!is.null(maxy))
maxy <- as.numeric(maxy)
if (!is.null(minz))
minz <- as.numeric(minz)
if (!is.null(maxz))
maxz <- as.numeric(maxz)
if (!missing(coolexp)) {
warning("Argument `coolexp' is deprecated and has no effect")
}
if (!missing(maxdelta)) {
warning("Argument `maxdelta' is deprecated and has no effect")
}
if (!missing(area)) {
warning("Argument `area' is deprecated and has no effect")
}
if (!missing(repulserad)) {
warning("Argument `repulserad' is deprecated and has no effect")
}
on.exit(.Call(C_R_igraph_finalizer))
if (dim == 2) {
res <- .Call(C_R_igraph_layout_fruchterman_reingold,
graph, coords, niter, start.temp, weights, minx,
maxx, miny, maxy, grid)
}
else {
res <- .Call(C_R_igraph_layout_fruchterman_reingold_3d,
graph, coords, niter, start.temp, weights, minx,
maxx, miny, maxy, minz, maxz)
}
res
}
<bytecode: 0x000001e2d8cbfec8>
<environment: namespace:igraph>
能量布局算法(energy placement methods). Kamada-Kawai layout algorithm.
plot(g.l, layout=layout_with_kk)
title("5x5x5 Lattice")
plot(aidsblog, layout=layout_with_kk)
title("Blog Network")
在有些情況下,希望強(qiáng)調(diào)網(wǎng)絡(luò)圖中的特殊結(jié)構(gòu)拿诸。樹就是其中之一扒袖。如:
g.tree <- graph_from_literal(1-+2,1-+3,1-+4,2-+5,2-+6,
2-+7,3-+8,3-+9,4-+10)
par(mfrow=c(1, 3))
igraph_options(vertex.size=30, edge.arrow.size=0.5,
vertex.label=NULL)
plot(g.tree, layout=layout_in_circle)
plot(g.tree, layout=layout_as_tree(g.tree, circular=T))
plot(g.tree, layout=layout_as_tree)
節(jié)點(diǎn)多了就不好看出來(lái)了
par(mfrow=c(1, 2))
plot(g.l, layout=layout_as_tree)
title("5x5x5 Lattice")
plot(aidsblog, layout=layout_as_tree)
title("Blog Network")
二部圖通常采用類似火車軌道的布局。
plot(g.bip, layout= -layout_as_bipartite(g.bip)[,2:1],
vertex.size=60, vertex.shape=ifelse(V(g.bip)$type,
"rectangle", "circle"),
vertex.label.cex=1.75,
vertex.color=ifelse(V(g.bip)$type, "red", "cyan"))
修飾圖的布局
網(wǎng)絡(luò)圖的可視化中亩码,節(jié)點(diǎn)的相對(duì)位置和邊的布置相當(dāng)重要季率。但如果存在其他節(jié)點(diǎn)和邊的信息,可以通過(guò)調(diào)整節(jié)點(diǎn)的大小顏色和邊的粗細(xì)來(lái)整合描沟,這就是圖的修飾飒泻。
我們用一個(gè)俱樂(lè)部網(wǎng)絡(luò)來(lái)演示圖的修飾鞭光,節(jié)點(diǎn)代表俱樂(lè)部成員,邊代表兩者的關(guān)系泞遗。俱樂(lè)部中有主管和教練衰猛,組成了兩個(gè)小團(tuán)體。如何在圖中刻畫這種關(guān)系呢刹孔?
library(igraphdata)
data(karate)
# Reproducible layout
set.seed(42)
l <- layout_with_kk(karate)
# Plot undecorated first.
igraph_options(vertex.size=10)
karate
IGRAPH 4b458a1 UNW- 34 78 -- Zachary's karate club network
+ attr: name (g/c), Citation (g/c), Author (g/c), Faction (v/n), name (v/c), label (v/c), color
| (v/n), weight (e/n)
+ edges from 4b458a1 (vertex names):
[1] Mr Hi --Actor 2 Mr Hi --Actor 3 Mr Hi --Actor 4 Mr Hi --Actor 5 Mr Hi --Actor 6
[6] Mr Hi --Actor 7 Mr Hi --Actor 8 Mr Hi --Actor 9 Mr Hi --Actor 11 Mr Hi --Actor 12
[11] Mr Hi --Actor 13 Mr Hi --Actor 14 Mr Hi --Actor 18 Mr Hi --Actor 20 Mr Hi --Actor 22
[16] Mr Hi --Actor 32 Actor 2--Actor 3 Actor 2--Actor 4 Actor 2--Actor 8 Actor 2--Actor 14
[21] Actor 2--Actor 18 Actor 2--Actor 20 Actor 2--Actor 22 Actor 2--Actor 31 Actor 3--Actor 4
[26] Actor 3--Actor 8 Actor 3--Actor 9 Actor 3--Actor 10 Actor 3--Actor 14 Actor 3--Actor 28
[31] Actor 3--Actor 29 Actor 3--Actor 33 Actor 4--Actor 8 Actor 4--Actor 13 Actor 4--Actor 14
+ ... omitted several edges
par(mfrow=c(1,1))
plot(karate, layout=l, vertex.label=V(karate),
vertex.color=NA)
未經(jīng)修飾的圖
# Now decorate, starting with labels.
V(karate)$label <- sub("Actor ", "", V(karate)$name)
# Two leaders get shapes different from club members.
V(karate)$shape <- "circle"
V(karate)[c("Mr Hi", "John A")]$shape <- "rectangle"
# Differentiate two factions by color.
V(karate)[Faction == 1]$color <- "red"
V(karate)[Faction == 2]$color <- "dodgerblue"
# Vertex area proportional to vertex strength
# (i.e., total weight of incident edges).
V(karate)$size <- 4*sqrt(strength(karate))
V(karate)$size2 <- V(karate)$size * .5
# Weight edges by number of common activities
E(karate)$width <- E(karate)$weight
# Color edges by within/between faction.
F1 <- V(karate)[Faction==1]
F2 <- V(karate)[Faction==2]
E(karate)[ F1 %--% F1 ]$color <- "pink"
E(karate)[ F2 %--% F2 ]$color <- "lightblue"
E(karate)[ F1 %--% F2 ]$color <- "yellow"
# Offset vertex labels for smaller points (default=0).
V(karate)$label.dist <-
ifelse(V(karate)$size >= 9.0, 0, 1.0)
# Plot decorated graph, using same layout.
plot(karate, layout=l)
修飾另一個(gè)律師網(wǎng)
# CHUNK 9
par(mfrow=c(1,2))
library(sand)
data(lazega)
lazega
IGRAPH 3e8b2bf UN-- 36 115 --
+ attr: name (v/c), Seniority (v/n), Status (v/n), Gender (v/n), Office (v/n), Years (v/n), Age
| (v/n), Practice (v/n), School (v/n)
+ edges from 3e8b2bf (vertex names):
[1] V1 --V17 V2 --V7 V2 --V16 V2 --V17 V2 --V22 V2 --V26 V2 --V29 V3 --V18 V3 --V25 V3 --V28 V4 --V12
[12] V4 --V17 V4 --V19 V4 --V20 V4 --V22 V4 --V26 V4 --V28 V4 --V29 V4 --V31 V5 --V18 V5 --V24 V5 --V28
[23] V5 --V31 V5 --V32 V5 --V33 V6 --V24 V6 --V28 V6 --V30 V6 --V31 V6 --V32 V7 --V18 V9 --V12 V9 --V16
[34] V9 --V29 V10--V24 V10--V26 V10--V29 V10--V31 V10--V34 V11--V17 V12--V15 V12--V16 V12--V17 V12--V19
[45] V12--V26 V12--V29 V12--V34 V13--V31 V13--V33 V14--V16 V14--V17 V14--V25 V14--V28 V14--V30 V14--V32
[56] V15--V16 V15--V19 V15--V20 V15--V22 V15--V24 V15--V26 V15--V29 V15--V32 V15--V35 V15--V36 V16--V17
[67] V16--V22 V16--V26 V16--V27 V16--V29 V16--V32 V16--V34 V16--V36 V17--V19 V17--V22 V17--V24 V17--V25
+ ... omitted several edges
plot(lazega)
# Office location indicated by color.
colbar <- c("red", "dodgerblue", "goldenrod")
v.colors <- colbar[V(lazega)$Office]
# Type of practice indicated by vertex shape.
v.shapes <- c("circle", "square")[V(lazega)$Practice]
# Vertex size proportional to years with firm.
v.size <- 3.5*sqrt(V(lazega)$Years)
# Label vertices according to seniority.
v.label <- V(lazega)$Seniority
# Reproducible layout.
set.seed(42)
l <- layout_with_fr(lazega)
plot(lazega, layout=l, vertex.color=v.colors,
vertex.shape=v.shapes, vertex.size=v.size,
vertex.label=v.label)
可視化大型網(wǎng)絡(luò)
到目前為止场钉,我們繪制的圖節(jié)點(diǎn)數(shù)量均小于100個(gè)鞋既,當(dāng)節(jié)點(diǎn)數(shù)大于100時(shí)圖會(huì)顯得十分凌亂苞轿,這時(shí)候不同布局算法所反應(yīng)的信息往往不同瘦锹。也有專門可視化大型網(wǎng)絡(luò)的布局算法,如VxOrd.
# CHUNK 12
set.seed(42)
l = layout_with_kk(fblog)
party.nums.f <- as.factor(V(fblog)$PolParty)
party.nums <- as.numeric(party.nums.f)
# igraph color palette has 8 colors
# 9 colors needed (for 9 political parties)
library(RColorBrewer)
colrs <- brewer.pal(9,"Set1")
V(fblog)$color <- colrs[party.nums]
plot(fblog, layout=l, vertex.label=NA,
vertex.size=3)
# CHUNK 13
set.seed(42)
l <- layout_with_drl(fblog)
plot(fblog, layout=l, vertex.size=5, vertex.label=NA)
存在聚集性并且可以明顯的特征化方库,可能是使用了某個(gè)觀測(cè)變量结序,也可能是通過(guò)圖分割算法推斷的結(jié)果。在可視化之前先將成組的點(diǎn)用meta-vertices代替纵潦,實(shí)現(xiàn)粗列旌祝化。
# CHUNK 14
fblog.c <- contract(fblog, party.nums)
E(fblog.c)$weight <- 1
fblog.c <- simplify(fblog.c)
# CHUNK 15
party.size <- as.vector(table(V(fblog)$PolParty))
plot(fblog.c, vertex.size=5*sqrt(party.size),
vertex.label=party.names, vertex.color=colrs,
edge.width=sqrt(E(fblog.c)$weight),
vertex.label.dist=3.5, edge.arrow.size=0)
有時(shí)候我們想展示某些特定的信息邀层,另一種方式是只展示相關(guān)的子圖返敬。描述局部結(jié)構(gòu)可以用個(gè)體中心網(wǎng)絡(luò)。
# CHUNK 16
data(karate)
k.nbhds <- make_ego_graph(karate, order=1)
# CHUNK 17
sapply(k.nbhds, vcount)
# ---
## [1] 17 10 11 7 4 5 5 5 6 3 4 2 3 6 3 3 3
## [18] 3 3 4 3 3 3 6 4 4 3 5 4 5 5 7 13 18
# ---
# CHUNK 18
k.1 <- k.nbhds[[1]]
k.34 <- k.nbhds[[34]]
par(mfrow=c(1,2))
plot(k.1, vertex.label=NA,
vertex.color=c("red", rep("lightblue", 16)))
plot(k.34, vertex.label=NA,
vertex.color=c(rep("lightblue", 17), "red"))
其他可視化工具
盡管使用R有許多的優(yōu)點(diǎn)寥院,但是畢竟還不能實(shí)時(shí)調(diào)控劲赠。還有許多界面軟件可以使用。
- Graphviz
- Pajek
- Cytoscape
- Gephi
- qgraph
等等秸谢。
https://blog.csdn.net/u012935646/article/details/107808259
https://photo.wondershare.com/graph-maker/best-tool-for-graph-visualization-online.html
EADES P. A heuristic for graph drawing[J]. Congressus numerantium, 1984, 42: 149-160.
https://blog.csdn.net/xyisv/article/details/104135708
https://cloud.tencent.com/developer/article/1483027
北京大學(xué)圖可視分析系列
https://blog.csdn.net/hei653779919/article/details/106861213
https://www.yuque.com/antv/g6/fvuhbz
LEACH分簇算法實(shí)現(xiàn)和能量控制算法實(shí)現(xiàn)
http://www.bu.edu/cs/files/2014/05/Kolaczyk.pdf
https://kateto.net/network-visualization