<jupyter_start><jupyter_text>Models This notebook shows how to load some graphs based on simple models.<jupyter_code>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, svg_digraph<jupyter_output><empty_output><jupyter_text>Graphs **Erdos-Renyi model**<jupyter_code>adjacency = erdos_renyi(20, 0.2)
image = svg_graph(adjacency)
SVG(image)<jupyter_output><empty_output><jupyter_text>**Stochastic block model**<jupyter_code>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)<jupyter_output><empty_output><jupyter_text>**Linear graph**<jupyter_code>graph = linear_graph(8, metadata=True)
adjacency = graph.adjacency
position = graph.position
image = svg_graph(adjacency, position)
SVG(image)
# adjacency matrix only
adjacency = linear_graph(8)<jupyter_output><empty_output><jupyter_text>**Cyclic graph**<jupyter_code>graph = cyclic_graph(8, metadata=True)
adjacency = graph.adjacency
position = graph.position
image = svg_graph(adjacency, position, width=200, height=200)
SVG(image)<jupyter_output><empty_output><jupyter_text>**Grid**<jupyter_code>graph = grid(6, 4, metadata=True)
adjacency = graph.adjacency
position = graph.position
image = svg_graph(adjacency, position)
SVG(image)<jupyter_output><empty_output><jupyter_text>**Albert-Barabasi model**<jupyter_code>adjacency = albert_barabasi(n=100, degree=3)
image = svg_graph(adjacency, labels={i:0 for i in range(3)}, display_node_weight=True, node_order=np.flip(np.arange(100)))
SVG(image)<jupyter_output><empty_output><jupyter_text>**Watts-Strogatz model**<jupyter_code>adjacency = watts_strogatz(n=100, degree=6, prob=0.2)
image = svg_graph(adjacency, display_node_weight=True, node_size_max=10)
SVG(image)<jupyter_output><empty_output><jupyter_text>Digraphs **Linear graph**<jupyter_code>graph = linear_digraph(8, metadata=True)
adjacency = graph.adjacency
position = graph.position
image = svg_digraph(adjacency, position)
SVG(image)<jupyter_output><empty_output><jupyter_text>**Cyclic graph**<jupyter_code>graph = cyclic_digraph(8, metadata=True)
adjacency = graph.adjacency
position = graph.position
image = svg_digraph(adjacency, position, width=200, height=200)
SVG(image)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12429831595829992, 'fraction_numerical': 0.022052927024859663, 'mean_word_length': 11.230392156862745, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '272927', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 991, 'n_tokens_neox': 919, 'n_words': 145, 'path': 'docs/tutorials/data/models.ipynb', 'repo_name': 'abidlabs/scikit-network', 'size': '2494'}