Gephi 官方手冊:一款關(guān)系可視化網(wǎng)絡(luò)圖工具的簡明教程

Gephi 和網(wǎng)絡(luò)圖

今天要分享的一款網(wǎng)絡(luò)圖工具:Gephi。

你可能沒聽過 Gephi匠璧,但說起百度的 Echarts和阿里的 Antv Data豁辉,一定不陌生把将。

在這兩款的數(shù)據(jù)可視化產(chǎn)品的解決方案中,描述「對象與對象之間有關(guān)聯(lián)關(guān)系或相互作用」的數(shù)據(jù)表現(xiàn)形式時(shí)王财,分別采用了「關(guān)系圖」和「一般圖」來描述卵迂。

Echarts


Echarts

Antv


Antv

看了上面的圖你一定對本文要介紹的內(nèi)容有了基本的輪廓了。

「網(wǎng)絡(luò)圖」是對一類關(guān)系型圖表的泛稱绒净,多用于一些關(guān)系型網(wǎng)絡(luò)的數(shù)據(jù)分析的場景见咒,例如社交網(wǎng)絡(luò)分析、生物網(wǎng)絡(luò)分析挂疆。

「網(wǎng)絡(luò)圖」描述的是多個節(jié)點(diǎn)之間的相關(guān)(互)關(guān)系改览,包含網(wǎng)絡(luò)中心性、度缤言、中間性和親密性等指標(biāo)宝当,其他的還包括密度、路徑長度胆萧、模塊化和聚類系數(shù)等庆揩。

聽球不懂

Don't worry,不要不戰(zhàn)而退。

我第一次看到英文介紹的時(shí)候腦仁兒也有點(diǎn)炸盾鳞,但這些指標(biāo)是網(wǎng)絡(luò)圖的數(shù)據(jù)分析核心犬性,不得不提,但并非不得不理解腾仅。其實(shí)如果你有深度應(yīng)用的需求,就能逐步在實(shí)驗(yàn)過程中理解并消化這些看上去生澀的知識點(diǎn)套利,在此不贅述推励。

今天我將以一個社交網(wǎng)絡(luò)分析的實(shí)驗(yàn)來貫穿對官網(wǎng)「gephi-tutorial-quick_start」的介(fān)紹(yì)。

先到官網(wǎng)瞅一瞅→ Gephi 官網(wǎng)

官網(wǎng)

這款開源免費(fèi)的網(wǎng)絡(luò)圖可視化工具最新版本為 0.9.2肉迫,可運(yùn)行于 Windows, Mac OS X and Linux验辞,三平臺通殺。點(diǎn)擊【Download FREE Gephi0.9.2】下載 Gephi喊衫。

官網(wǎng)描述其四大特點(diǎn):

  • 人人都會:不需要編程技術(shù)就可以構(gòu)建你想要的網(wǎng)絡(luò)圖(然而 Gephi 是支持 code 的??)
  • 顏值擔(dān)當(dāng):專有的渲染引擎跌造,助力高質(zhì)量的視覺展現(xiàn)
  • 本地支持:支持包含眾多本地文件格式,也就是說不需要網(wǎng)絡(luò)支撐也可以用
  • 高定制化:包括布局族购、指標(biāo)壳贪、數(shù)據(jù)源、工具箱和渲染預(yù)設(shè)等寝杖,都可以通過插件實(shí)現(xiàn)定制化

聽起來就很美违施,對不對~

Downloading...

下載安裝完成開始使用,發(fā)現(xiàn)有一份兒《Gephi 快速上手指南》擺在我們面前瑟幕,不多說打開它磕蒲。

手冊簡明的介紹了 Gephi 的基本使用方法,包含:

  • 導(dǎo)入文件(數(shù)據(jù))
  • 可視化圖表
  • 布局設(shè)置
  • 按節(jié)點(diǎn)的屬性(顏色和尺寸)排列
  • 分區(qū)只盹、數(shù)據(jù)過濾
  • 預(yù)覽辣往、導(dǎo)出、保存
image

Gephi Tutorial Quick Start

Welcome to this introduction tutorial. It will guide you to the basic steps of network visualization and manipulation in Gephi.
Gephi version 0.7alpha2 was used to do this tutorial.

歡迎使用 Gephi 指南殖卑。該指南會告訴你學(xué)會在 Gephi 中構(gòu)建網(wǎng)絡(luò)可視化站削、操作的基本步驟。使用版本是 V 0.7alpha2懦鼠。

Open Graph File

  • Download the file LesMiserables.gexf
  • In the menubar, go to File Menu and Open...


    image

P.S 指南提供了一個文件钻哩,我實(shí)驗(yàn)中用的是另一個文件)

打開文件。在菜單欄中肛冶,找到并打開你的文件可以編輯已有的圖街氢。Gephi 支持的文件格式很多...

重要的是支持 Excel 格式! 重要的是支持 Excel 格式睦袖! 重要的是支持 Excel 格式珊肃!

聽到老熟人 Excel,是否突然感覺學(xué)習(xí)曲線變平緩了很多???????

這里選擇打開一個 xls 文件伦乔,里面包含 nodes 表厉亏、 edges 表。

nodes 表里放節(jié)點(diǎn)的數(shù)據(jù)烈和,edges 放關(guān)系數(shù)據(jù)爱只。

nodes 表里數(shù)據(jù)需要最基本的是 id,edges 表里數(shù)據(jù)需要最基本的是 source 和 target招刹。

nodes 表恬试,除了必須的 id 外,我還記錄了 Label疯暑,用于網(wǎng)絡(luò)圖的節(jié)點(diǎn)名字顯示训柴。

image

edges 表,除了必須的兩個字段妇拯,我還記錄了 id,Weight,type,label幻馁,但這些都不是必須的。

image

(p.s 我實(shí)測 xlsx 在有多個 sheet 的時(shí)候存在問題越锈,沒有專研問題仗嗦,你們可自行測試)

分別導(dǎo)入 sheet1 和 sheet2(對,兩次)瞪浸,對應(yīng)選擇導(dǎo)入類型 import as 為 Nodes table 和 Edges table

image

Import Report

When your filed is opened, the report sum up data found and issues.

  • Number of nodes
  • Number of edges
  • Type of graph

Click on OK to validate and see the graph


image

導(dǎo)入報(bào)告儒将。當(dāng)你打開文件后,報(bào)告會呈現(xiàn)匯總數(shù)據(jù)和問題对蒲,包含:

  • 節(jié)點(diǎn)的數(shù)量
  • 邊的數(shù)量(節(jié)點(diǎn)之間關(guān)系)
  • 圖表類型(有向圖 or 無向圖)

點(diǎn)擊【ok】驗(yàn)證查看圖表

You should now see a graph

Nodes position is random at first, so you may see a slighty different representation.


image

你可以看到導(dǎo)入的數(shù)據(jù)生成的網(wǎng)絡(luò)圖了钩蚊。節(jié)點(diǎn)位置都是隨機(jī)生成的,所以你可能看到的和想象當(dāng)中的有點(diǎn)點(diǎn)區(qū)別蹈矮。

Graph Visualization

  • Use your mouse to move and scale the visualization - Zoom: Mouse Wheel - Pan: Right Mouse Drag
  • Locate the “Edge Thickness” slider on the bottom
  • If you loose your graph, reset the position
image

圖表可視化砰逻。用鼠標(biāo)滾輪和郵件可以移動、縮放圖像泛鸟,調(diào)整 "Edge Thickness" 控制線條的粗細(xì)蝠咆,"reset the position" 可以幫助你將圖像縮放到最全視角

Layout the graph

Layout algorithms sets the graph shape, it is the most essential action.

  • Locate the Layout module, on the left panel.
  • Choose“Force Atlas”,You can see the layout properties below, leave default values.
  • Click on 【Run】to launch the algorithm
image

設(shè)置圖表的布局。系統(tǒng)內(nèi)預(yù)置的布局的算法設(shè)定圖表的展現(xiàn)北滥,不可或缺刚操。在左側(cè)的 Layout 面板中選擇 "Force Atlas",面板會顯示對應(yīng)的屬性設(shè)置再芋,保持默認(rèn)設(shè)置點(diǎn)擊【Run】啟動算法菊霜。

Control the layout

The purpose of Layout Properties is to let you control the algorithm in order to make a aesthetically pleasing representation.

  • Set the“Repulsion strengh”at 10 000 to expand the graph.
  • Type“Enter”to validate the changed value.
  • And now【Stop】 the algorithm.
image

控制布局。布局算法的屬性的目的是為了使網(wǎng)絡(luò)圖有更賞心悅目的展現(xiàn)效果济赎。將 “Repulsion strengh” 的值設(shè)置為 10000 以便于讓圖表更舒展鉴逞,回車確認(rèn)修改(后可以看到效果)记某,然后點(diǎn)擊【Stop】停止算法。

你現(xiàn)在可以看到調(diào)整后的圖表的布局樣子构捡。

image

Ranking (color)

Ranking module lets you configure node’s color and size.

Locate Ranking module, in the top left.

  • Choose “Degree” as a rank parameter.
  • Click on 【Apply】to see the result.
image

Let's configure colors>

  • Move your mouse over the gradient component
  • Double-click on triangles to configure the color
image

排列(按顏色)液南。排列模塊讓你可以配置節(jié)點(diǎn)的顏色和大小。你可以在左上側(cè)找到 Appearance 面板找到 Nodes→ Ranking勾徽,在下拉框中選擇 “Degree” 作為排列的參數(shù)滑凉,然后點(diǎn)擊【Apply】就可以看到結(jié)果。

配置顏色捂蕴。鼠標(biāo)在滑條上可改變顏色的梯度譬涡,雙擊三角形可以配置顏色。點(diǎn)擊右側(cè)
image

可以使用默認(rèn)的配色方案啥辨。

Ranking result table

(我在當(dāng) 0.9.2 版本中沒有此功能,后面問清楚了我在補(bǔ)充到文章中)

Metrics

We will calculate the average path length for the network. It computes the path length for all possibles pairs of nodes and give information about how nodes are close from each other.

  • Locate the Statistics module on the right panel.
  • Click on 【Run】 near “Average Path Length”.
image

Metrics available

image

指標(biāo)度量盯腌。我們將計(jì)算所有可能的配對的節(jié)點(diǎn)的路徑長度的均值作為網(wǎng)絡(luò)的「平均路徑長度」溉知,以便于我們知道節(jié)點(diǎn)于節(jié)點(diǎn)之間的親密程度。定位到右側(cè)的 Statistics 模塊腕够,找到“Average Path Length”级乍,點(diǎn)擊【Run】運(yùn)行。

運(yùn)行完成會得到一個報(bào)告反饋帚湘,告訴及計(jì)算的結(jié)果玫荣,比如這里報(bào)告了中間性,集中性等情況大诸。

image

Ranking(Size)

Metrics generates general reports but also results for each node. Thus three new values have been created by the “Average Path Length” algorithm we ran

  • Betweeness Centrality
  • Closeness Centrality
  • Eccentricity

指標(biāo)度量不只是生成報(bào)告同樣會影響到每一個節(jié)點(diǎn)捅厂。我們運(yùn)行 “Average Path Length” 算法以后,會生成三個新值资柔,分別是 Betweeness Centrality ,Closeness Centrality ,Eccentricity焙贷。

  • Go back to Ranking
  • Select“Betweeness Centrality” in the list.
  • This metrics indicates influencial nodes for highest value.
image

返回到排列中。選擇 “Betweeness Centrality” 參數(shù)贿堰。這個指標(biāo)會直接指明最有影響力的節(jié)點(diǎn)辙芍。

Ranking(Size)

The node's size will be set now.Colors remain the"Degree"indicator.>

  • Sselect the diamond icon in the toolbar for size
  • Set a min size at 10 and a manx sieze at 50
  • And click on 【Apply】 to see the result.

現(xiàn)在我們來設(shè)置節(jié)點(diǎn)的尺寸大小。顏色保持使用 “Degree” 的指標(biāo)羹与。選擇工具欄上的尺寸圖標(biāo)故硅,設(shè)置尺寸最小為 10 ,最大為 50纵搁,然后點(diǎn)擊【Apply】查看結(jié)果吃衅。

image

Layout again

The layout is not completely satisfying,as big nodes can overlap smaller.
The “Force Atlas” algorithm has an option to take node size in account when layouting.

  • Go Back to the Layout panel.
  • Check the “Adjust by Sizes” option and run again the algorithm for short moment.
  • You can see nodes are not overlapping anymore

再次布局」羁剩可以看到布局并非完全讓你滿意捐晶,例如一些大的節(jié)點(diǎn)就會重疊在較小的節(jié)點(diǎn)之上形成覆蓋菲语。“Force Atlas”算法則有一些設(shè)置項(xiàng)在布局時(shí)考慮到節(jié)點(diǎn)的尺寸惑灵。返回到 Layout 面板山上,將 “Adjust by Sizes” 勾選后重新運(yùn)行算法,節(jié)點(diǎn)此時(shí)不再重疊了英支。

Show Labels

Let's explore the network more in details now that colors and size indicates central nodes>

  • Dsiplay node labels
  • Set label size proportional to node size
  • Set label size with the scale slider
image

展示標(biāo)簽∨搴叮現(xiàn)在可以通過顏色和節(jié)點(diǎn)大小表明各個中心節(jié)點(diǎn),我們來探究一下更多細(xì)節(jié)干花。顯示節(jié)點(diǎn)的標(biāo)簽名稱妄帘,設(shè)置按節(jié)點(diǎn)尺寸匹配標(biāo)簽文本大小,通過滑條直接設(shè)置標(biāo)簽尺寸池凄。

Community detection

The ability to detect and study communities is central in network analysis.We would like to colorize clusters in our example.
Gephi implements the Louvain method,available form the Statistics panel.
Click on Run near the "Modularity" line

  • Select "Randomize" on the panel
  • Click on OK to lancuh the detection

社區(qū)群偵測抡驼。甄別和研究社區(qū)社群的能力是網(wǎng)絡(luò)分析的核心。這個例子中肿仑,我們將依賴 Gephi 在 Statistics 面板中提供的方法致盟,分集群對節(jié)點(diǎn)著色。點(diǎn)擊 run 運(yùn)行 Statistics 面板中的“Modularity”尤慰。對話框中選擇 "Randomize" 隨機(jī)分布馏锡,點(diǎn)擊 ok 運(yùn)行偵測。

Partition

The community detection algorithm created a "Modularity Class" value for each node.
The partition module can use this new data to colorize communities

  • Locate the Partition module on the left panel.
  • Immediately click on the "Refresh" button to populate the partition list.
  • Select "Modularity Class" in the partition list.
  • you can see that 9 communities were found,could be different for you.A random color has been set for each community indetifier
  • Click to Apply to colorize nodes.
image

分區(qū)伟端”溃“社群偵測算法”為每一個節(jié)點(diǎn)創(chuàng)建了 “Modularity Class”。節(jié)點(diǎn)的分區(qū) Partition 模塊里可以用這個新的參數(shù)給給不同的社群標(biāo)注不同的顏色(以便于區(qū)分出社區(qū)群體)责蝠。在左側(cè)的 Apprearance 面板中党巾,找到節(jié)點(diǎn)分區(qū)模塊,點(diǎn)擊【Refresh】按鈕去構(gòu)建分區(qū)列表玛歌。選擇“Mdoularity Class” 后昧港,節(jié)點(diǎn)被分為了 9 個不同的社群,每個社群有自己的顏色以便于區(qū)分支子。點(diǎn)擊 Apply 給渲染節(jié)點(diǎn)顏色创肥。

最終效果還是比較讓人滿意的。因?yàn)樯婕暗絺€人信息值朋,這里我沒有設(shè)置顯示節(jié)點(diǎn)的名稱叹侄。

image

Preview

  • Before exporting you graph as a SVG or PDF file,go to Preview to:
    • See exactly how the graph will look like
    • Put the last touch
  • Select the "Preview" tab in the banner:
  • Click on Refresh to see the preview
  • Preview Settings sipports Presets,click on the presets list and try different configuration

預(yù)覽。導(dǎo)出 SVG 或 PDF 之前昨登,先預(yù)覽一下趾代。這樣可以直觀的看到圖像的外觀然后做一些最后處理。選擇 “Preview” 選項(xiàng)卡丰辣,點(diǎn)擊 Refresh 查看預(yù)覽撒强。有一些預(yù)設(shè)的預(yù)覽設(shè)定可以選擇禽捆,嘗試不同的風(fēng)格。

image

(這里我隱藏了 Label)

最后導(dǎo)出為 SVG/PDF/PNG 就隨你心情了飘哨。

Conclusion

In this tutorial you learned the baisc process to open,visualize,manipulate and render a network file with Gephi
Go furhter:https://gephi.org/users/

image

這份指南讓你學(xué)習(xí)如何用 Gephi 打開文件胚想、可視化、操作和渲染網(wǎng)絡(luò)芽隆,若想深入學(xué)習(xí)浊服,可以參照官方文檔:https://gephi.org/users/

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末胚吁,一起剝皮案震驚了整個濱河市牙躺,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌腕扶,老刑警劉巖孽拷,帶你破解...
    沈念sama閱讀 219,490評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異半抱,居然都是意外死亡乓搬,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,581評論 3 395
  • 文/潘曉璐 我一進(jìn)店門代虾,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人激蹲,你說我怎么就攤上這事棉磨。” “怎么了学辱?”我有些...
    開封第一講書人閱讀 165,830評論 0 356
  • 文/不壞的土叔 我叫張陵乘瓤,是天一觀的道長。 經(jīng)常有香客問我策泣,道長衙傀,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,957評論 1 295
  • 正文 為了忘掉前任萨咕,我火速辦了婚禮统抬,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘危队。我一直安慰自己聪建,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,974評論 6 393
  • 文/花漫 我一把揭開白布茫陆。 她就那樣靜靜地躺著金麸,像睡著了一般。 火紅的嫁衣襯著肌膚如雪簿盅。 梳的紋絲不亂的頭發(fā)上挥下,一...
    開封第一講書人閱讀 51,754評論 1 307
  • 那天揍魂,我揣著相機(jī)與錄音,去河邊找鬼棚瘟。 笑死现斋,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的解取。 我是一名探鬼主播步责,決...
    沈念sama閱讀 40,464評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼禀苦!你這毒婦竟也來了蔓肯?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,357評論 0 276
  • 序言:老撾萬榮一對情侶失蹤振乏,失蹤者是張志新(化名)和其女友劉穎蔗包,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體慧邮,經(jīng)...
    沈念sama閱讀 45,847評論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡调限,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,995評論 3 338
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了误澳。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片耻矮。...
    茶點(diǎn)故事閱讀 40,137評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖忆谓,靈堂內(nèi)的尸體忽然破棺而出裆装,到底是詐尸還是另有隱情,我是刑警寧澤倡缠,帶...
    沈念sama閱讀 35,819評論 5 346
  • 正文 年R本政府宣布哨免,位于F島的核電站,受9級特大地震影響昙沦,放射性物質(zhì)發(fā)生泄漏琢唾。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,482評論 3 331
  • 文/蒙蒙 一盾饮、第九天 我趴在偏房一處隱蔽的房頂上張望采桃。 院中可真熱鬧,春花似錦丐谋、人聲如沸芍碧。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,023評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽泌豆。三九已至,卻和暖如春吏饿,著一層夾襖步出監(jiān)牢的瞬間踪危,已是汗流浹背蔬浙。 一陣腳步聲響...
    開封第一講書人閱讀 33,149評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留贞远,地道東北人畴博。 一個月前我還...
    沈念sama閱讀 48,409評論 3 373
  • 正文 我出身青樓,卻偏偏與公主長得像蓝仲,于是被迫代替她去往敵國和親俱病。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,086評論 2 355

推薦閱讀更多精彩內(nèi)容

  • 這一章講的比特幣的交易記錄的細(xì)節(jié)袱结。通過這一章你可以理解亮隙,比特幣的交易是采用什么樣的組織形式構(gòu)成的,同時(shí)也可以看到垢夹,...
    Scalers閱讀 2,223評論 1 3
  • 雨雪清明上祭親溢吻, 賢靈天國自禔身。 風(fēng)寒薄暮燒冥紙果元, 盡是悠哀念故人促王。 注:仄起首句入韻式。 禔而晒,zhī蝇狼。
    西山有晴雪閱讀 572評論 23 64
  • 這個周末相當(dāng)忙碌了题翰。 雖然周五喝多了但是毫不影響周六上午聽講座,周六下午去公司接待客戶诈胜,周天上午接待客戶,下午主持...
    好_好_蘇閱讀 273評論 3 3
  • 所有事情都有一個結(jié)局冯事,在某個界限之前焦匈,結(jié)局是可以被自己的努力填補(bǔ)的,那么我應(yīng)該為了那個存在的界限昵仅,而放棄自己現(xiàn)在的...
    曷木閱讀 156評論 0 1