<jupyter_start><jupyter_text>Core decomposition This notebook illustrates the $k$-core decomposition of graphs.<jupyter_code>from IPython.display import SVG
import numpy as np
from sknetwork.data import karate_club, painters
from sknetwork.topology import CoreDecomposition
from sknetwork.visualization import svg_graph, svg_digraph
from sknetwork.utils import directed2undirected<jupyter_output><empty_output><jupyter_text>Graphs<jupyter_code>graph = karate_club(metadata=True)
adjacency = graph.adjacency
position = graph.position
core = CoreDecomposition()
labels = core.fit_transform(adjacency)
image = svg_graph(adjacency, position, scores=labels)
SVG(image)<jupyter_output><empty_output><jupyter_text>Directed graphs<jupyter_code>graph = painters(metadata=True)
adjacency = graph.adjacency
names = graph.names
position = graph.position
labels = core.fit_transform(directed2undirected(adjacency))
image = svg_digraph(adjacency, position, names, scores=labels)
SVG(image)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0845771144278607, 'fraction_numerical': 0.001990049751243781, 'mean_word_length': 10.054945054945055, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '407902', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 330, 'n_tokens_neox': 310, 'n_words': 65, 'path': 'docs/tutorials/topology/core_decomposition.ipynb', 'repo_name': 'pmla/scikit-network', 'size': '1005'}