Scikit-network-03:基于简单模型加载图

Models

基于简单模型加载一些图形

from IPython.display import SVG

import numpy as np

from sknetwork.data import erdos_renyi, block_model, linear_graph, cyclic_graph, linear_digraph, cyclic_digraph, grid, albert_barabasi, watts_strogatz
from sknetwork.visualization import svg_graph
Erdos-Renyi model
adjacency = erdos_renyi(20, 0.2)

image = svg_graph(adjacency)
SVG(image)

在这里插入图片描述

Stochastic block model
graph = block_model([20, 25, 30], p_in=[0.5, 0.4, 0.3], p_out=0.02, metadata=True)
adjacency = graph.adjacency
labels = graph.labels

image = svg_graph(adjacency, labels=labels)
SVG(image)

在这里插入图片描述

Linear graph
graph = linear_graph(8, metadata=True)
adjacency = graph.adjacency
position = graph.position

image = svg_graph(adjacency, position)
SVG(image)

在这里插入图片描述

# adjacency matrix only
graph = linear_graph(8)

# directed
graph = linear_digraph(8, metadata=True)
adjacency = graph.adjacency
position = graph.position

image = svg_graph(adjacency, position)
SVG(image)

在这里插入图片描述

Cyclic graph
graph = cyclic_graph(8, metadata=True)

adjacency = graph.adjacency
position = graph.position
image = svg_graph(adjacency, position, width=200, height=200)
SVG(image)

在这里插入图片描述

Grid
graph = grid(6, 4, metadata=True)
adjacency = graph.adjacency
position = graph.position

image = svg_graph(adjacency, position)

SVG(image)

在这里插入图片描述

Albert-Barabasi model
adjacency = albert_barabasi(n=100, degree=3)

image = svg_graph(adjacency, labels={i:0 for i in range(3)}, display_edge_weight=True, node_order=np.flip(np.arange(100)))
SVG(image)

在这里插入图片描述

Watts-Strogatz model
adjacency = watts_strogatz(n=100, degree=6, prob=0.2)
image = svg_graph(adjacency, display_node_weight=True, node_size_max=10)
SVG(image)

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

uncle_ll

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值