網路導論

Python 網路分析入門

Eric Ma

Data Carpentry instructor and author of nxviz package

Networks!

  • 例子:

    • 社群

    • 運輸

  • 建立實體之間的關係模型

Python 網路分析入門

Networks!

  • 洞見:

  • 重要節點:社群網路的影響者

  • 路徑搜尋:最高效的運輸路徑

  • 分群:找出社群

Python 網路分析入門

網路結構

兩個節點

Python 網路分析入門

網路結構

由一條邊連接的兩個節點

Python 網路分析入門

網路結構

包含一條邊連接兩個節點的圖

Python 網路分析入門

網路結構

圖中兩節點以一條邊相連。節點標示為「Hugo」與「Eric」,邊的標示為「Friendship」。每個節點具有「id」與「age」的中介資料屬性,邊具有「date」的中介資料屬性。

Python 網路分析入門

NetworkX API 基礎

import networkx as nx

G = nx.Graph()
G.add_nodes_from([1, 2, 3])
G.nodes()
NodeView([1, 2, 3])
G.add_edge(1, 2)

G.edges()
EdgeView([(1, 2)])
Python 網路分析入門

NetworkX API 基礎

G.nodes[1]['label'] = 'blue'

G.nodes(data=True)
[(1, {'label': 'blue'}), (2, {}), (3, {})]
Python 網路分析入門

NetworkX API 基礎

nx.draw(G)

import matplotlib.pyplot as plt plt.show()

圖的節點連結圖示。

Python 網路分析入門

一起來練習吧!

Python 網路分析入門

Preparing Video For Download...