<jupyter_start><jupyter_text>Найти число вершин второй степени == 3<jupyter_code>import networkx as nx

g = nx.read_edgelist("2.graph.txt", nodetype=int)

node2deg = {}
edges = g.edges()

for node in g.nodes():
    deg = 0
    for (u, v) in edges:
        if u == node or v == node:
            continue
            
        if not (g.has_edge(u, node) or g.has_edge(v, node)):
            continue

        deg += 1
        
    node2deg[node] = deg
    
    if (node + 1) % 1000 == 0:
        print(node + 1)
len(filter(lambda _: _ == 3, node2deg.values()))
len(filter(lambda _: _ == 3, node2deg.values()))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1426332288401254, 'fraction_numerical': 0.02664576802507837, 'mean_word_length': 2.363157894736842, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '450706', 'license': 'MIT', 'n_tokens_mistral': 254, 'n_tokens_neox': 243, 'n_words': 58, 'path': 'webgraph-course/week-2/task-2.ipynb', 'repo_name': 'menshikh-iv/hw', 'size': '638'}