Katz 中心性
此笔记本演示了根据 Katz 中心性 对图节点进行排名,它是对到每个节点的不同长度路径数量的加权平均值。
[1]:
from IPython.display import SVG
[2]:
from sknetwork.data import karate_club, painters, movie_actor
from sknetwork.ranking import Katz
from sknetwork.visualization import visualize_graph, visualize_bigraph
图
[3]:
graph = karate_club(metadata=True)
adjacency = graph.adjacency
position = graph.position
[4]:
katz = Katz()
scores = katz.fit_predict(adjacency)
[5]:
image = visualize_graph(adjacency, position, scores=scores)
SVG(image)
[5]:
有向图
[6]:
graph = painters(metadata=True)
adjacency = graph.adjacency
names = graph.names
position = graph.position
[7]:
katz = Katz()
scores = katz.fit_predict(adjacency)
[8]:
image = visualize_graph(adjacency, position, scores=scores, names=names)
SVG(image)
[8]:
二部图
[9]:
graph = movie_actor(metadata=True)
biadjacency = graph.biadjacency
names_row = graph.names_row
names_col = graph.names_col
[10]:
katz = Katz()
katz.fit(biadjacency)
scores_row = katz.scores_row_
scores_col = katz.scores_col_
[11]:
image = visualize_bigraph(biadjacency, names_row, names_col, scores_row=scores_row, scores_col=scores_col)
SVG(image)
[11]: