در نقشهٔ پیوندِ یک مجموعهٔ سند، وجودِ مسیر از یک صفحه به صفحهٔ دیگر، بازگشت را تضمین نمی‌کند. برای بررسیِ ساختار، می‌توان اسنادی را که از راهِ پیوندهای جهت‌دار به یکدیگر دسترسی دارند در یک گروه قرار داد. این درس، گرافی کاملاً ساختگی را به مؤلفه‌های قویاً همبند و یک نمایشِ فشرده تبدیل می‌کند. هیچ وب‌سایتی خزش نمی‌شود و متن، کیفیت، اعتبار یا رتبهٔ اسناد ورودیِ محاسبه نیست.

۱. همبندیِ قوی را از پیوندِ یک‌طرفه جدا کنیم

مسیرِ بازگشت برای همبندیِ قوی لازم است
تصویر مفهومی: مسیرِ بازگشت برای همبندیِ قوی لازم است؛ بدون مقیاس عددی و مستقل از نتایج اجرای کد.

هشت شناسهٔ A تا H را سند فرض می‌کنیم. پیوندِ A به B فقط همان جهت را دارد؛ برنامه از روی آن، پیوندِ برگشت نمی‌سازد. دو سند در یک مؤلفه‌اند اگر مسیرِ رفت و مسیرِ برگشت، با هر تعداد پیوند، موجود باشند. گروه باید نسبت به این خاصیت بیشینه باشد؛ نمی‌توان یک عضوِ قابل‌دسترسیِ دوطرفه را دلخواه بیرون گذاشت. این تعریف به یکسان‌بودنِ متن یا عنوانِ سند وابسته نیست.

برای نمونه، A به B، B به C و C به A اشاره می‌کنند. پس با وجودِ نبودِ پیوندِ مستقیم میان بعضی زوج‌ها، هر سه در یک گروه‌اند. D و E نیز به یکدیگر پیوند دارند. C و B هر دو به D می‌رسند، اما تا اینجا مسیرِ بازگشت از D به آن سه نداریم؛ نزدیکیِ ظاهری در یک تصویر یا وجودِ یک اتصال، دو گروه را یکی نمی‌کند.

رابطهٔ دسترسی، مسیرِ بدون یال از هر گره به خودش را هم می‌پذیرد. بنابراین G که هیچ پیوندی ندارد، یک مؤلفهٔ تک‌عضوی است. این نتیجه به معنیِ وجودِ چرخهٔ با طولِ مثبت نیست. F در مثال به خودش پیوند دارد و از این نظر با G فرق می‌کند. برای بررسیِ جهت، گرافِ فقط A به B نیز مفید است: با نادیده گرفتنِ جهت متصل‌اند، ولی دو مؤلفهٔ قویِ جدا دارند.

در درسِ HITS و نقشِ هاب و مرجع، خروجی عددهای ساختاری بود. اینجا حتی پرسشِ جست‌وجو یا امتیاز نداریم؛ خروجی یک افراز از شناسه‌هاست. تعلق به یک مؤلفه، مجوزِ حذفِ سندِ تکراری، ادغامِ محتوا یا انتخابِ مرجعِ پاسخ نیست. همچنین نمی‌توان از آن، بهبودِ سئو یا اعتبارِ علمیِ یک صفحه را نتیجه گرفت.

۲. دو پیمایش و ترتیبِ پایان را درست به کار ببریم

دو پیمایشِ جدا و نقشِ ترتیبِ پایان
تصویر مفهومی: دو پیمایشِ جدا و نقشِ ترتیبِ پایان؛ بدون مقیاس عددی و مستقل از نتایج اجرای کد.

منبعِ اصلیِ نویسندگانِ Algorithms برای Kosaraju–Sharir، دو پیمایش را توضیح می‌دهد. نخست گرافِ وارونه را می‌پیماییم و گره را پس از تمام‌شدنِ فرزندانش در فهرستِ پایان می‌گذاریم. سپس در گرافِ اصلی، به ترتیبِ معکوسِ همان فهرست، از گره‌های هنوزدیده‌نشده پیمایش می‌کنیم. هر پیمایشِ تازه یک مؤلفه می‌دهد؛ صرفِ وارونه‌کردنِ نام‌ها جای وارونه‌کردنِ یال‌ها نیست.

دو مجموعهٔ دیده‌شده در کد، از نظرِ زمانِ استفاده جدا هستند. پس از پیمایشِ نخست، مجموعه پاک می‌شود؛ نگه‌داشتنِ علامت‌های قبلی باعث می‌شود دورِ دوم همهٔ گره‌ها را دیده‌شده فرض کند. جایِ ثبتِ پایان نیز مهم است: افزودنِ گره هنگامِ ورود، ترتیبِ پیش‌ورود می‌سازد و قراردادی که این روش لازم دارد نیست. مرجعِ آزمون از این فهرست استفاده نمی‌کند تا چنین خطاهایی را مستقل آشکار کند.

ورودیِ ما حداکثر هشت شناسه و شصت‌وچهار یال دارد؛ بازگشتِ تابع فقط در همین دامنهٔ کوچک استفاده می‌شود. این کران، خاصیتِ الگوریتم یا محدودیتِ وب نیست. دو پیمایش با فهرستِ همسایه‌ها هزینهٔ خطی نسبت به شمارِ گره‌ها و یال‌ها دارند، اما نسخهٔ حاضر برای نمایشِ قطعی، نام‌ها، گروه‌ها و یال‌های خروجی را مرتب هم می‌کند. پس هزینهٔ کلِ این فایل را بدون قید، همان هزینهٔ پیمایش نمی‌نامیم.

۳. هر مؤلفه را به یک گرهٔ فشرده تبدیل کنیم

هر گروهِ سند در نمایشِ فشرده یک نماینده دارد
تصویر مفهومی: هر گروهِ سند در نمایشِ فشرده یک نماینده دارد؛ بدون مقیاس عددی و مستقل از نتایج اجرای کد.

پس از پیدا کردنِ گروه‌ها، هر گروه یک نماینده می‌گیرد. پیوندِ میانِ دو سندِ داخلِ همان گروه، یالِ نمایشِ فشرده نمی‌شود؛ پیوندهای متعدد میانِ دو گروه نیز یک یال می‌سازند. قراردادِ condensation در NetworkX 3.7 این تبدیل و نگاشتِ عضوها به نماینده را توضیح می‌دهد. کدِ ما مستقل است و NetworkX را اجرا نمی‌کند.

پاسخِ دستیِ نمونه پنج گروه است: A و B و C؛ D و E؛ سپس F، G و H به‌صورتِ تک‌عضوی. عضوهای هر گروه و خودِ گروه‌ها با ترتیبِ رشته‌ای مرتب می‌شوند؛ شناسه‌های نماینده از صفر تا چهار، صرفاً شاخصِ همین نمایش‌اند. H به A پیوند دارد، پس یک یال از نمایندهٔ چهار به صفر داریم. کوچک‌تر بودنِ شناسه به معنیِ تقدمِ توپولوژیک، رتبهٔ بهتر یا اهمیتِ بیشتر نیست.

دو یالِ B به D و C به D در خروجی یک یال از صفر به یک می‌شوند؛ E به F نیز یالِ یک به دو می‌سازد. خودحلقهٔ F داخلِ گروهش حذف می‌شود و G نماینده‌ای بدون یال می‌ماند. فشرده‌سازی به معنیِ حذفِ ردیفِ اسناد نیست: نگاشتِ هر هشت شناسه نگه داشته می‌شود تا بتوان نتیجه را به دادهٔ ورودی برگرداند.

نمایشِ فشرده چرخهٔ جهت‌دار ندارد؛ اگر چند گروه روی یک چرخه بودند، مسیرِ رفت‌وبرگشت میانِ عضوهایشان وجود داشت و از ابتدا یک مؤلفه می‌شدند. این نتیجه، چرخه‌های داخلِ گرافِ اصلی را پاک یا اصلاح نکرده است. در درسِ ترتیبِ آماده‌سازی دانش فقط یک شاهدِ چرخه و کارهای متوقف‌شده را داشتیم؛ آن شاهد، افرازِ کاملِ مؤلفه‌ها نبود.

۴. کدِ کامل و مرجعِ مستقلِ دسترسی

مرجعِ دسترسی مستقل از دو پیمایش ساخته می‌شود
تصویر مفهومی: مرجعِ دسترسی مستقل از دو پیمایش ساخته می‌شود؛ بدون مقیاس عددی و مستقل از نتایج اجرای کد.

فایل document_link_components.py با Python 3.14.5 و کتابخانهٔ استاندارد اجرا شده است. شناسه‌ها دقیقاً رشته‌های ASCII با حرفِ بزرگِ آغازین و حداکثر هشت نویسه‌اند؛ ورودیِ شناسه‌ها و یال‌ها tuple است. مقصدِ ناشناخته، شناسهٔ تکراری، یالِ تکراری و شکلِ نادرست خطا می‌دهند. خودحلقه مجاز است. این قواعد قراردادِ تألیفیِ داده‌اند، نه نحوِ URL یا محدودیتِ سندِ فارسی.

"""Bounded supplied document-link graph, not a crawler or ranking model.

Own Python implementation of the two-pass Kosaraju traversal. Canonical
display IDs are NOT topological positions, quality scores or stable IDs.
"""
from itertools import product
import json
import platform
import re

NAME = re.compile(r'[A-Z][A-Z0-9_]{0,7}', re.ASCII)
MAX_NODES = 8


def supplied_graph(nodes, edges):
    if type(nodes) is not tuple or len(nodes) > MAX_NODES:
        raise ValueError('nodes_tuple')
    if any(type(n) is not str or NAME.fullmatch(n) is None for n in nodes):
        raise ValueError('node_name')
    if len(set(nodes)) != len(nodes):
        raise ValueError('duplicate_node')
    if type(edges) is not tuple or len(edges) > MAX_NODES ** 2:
        raise ValueError('edges_tuple')
    for edge in edges:
        if type(edge) is not tuple or len(edge) != 2:
            raise ValueError('edge_shape')
        if any(type(n) is not str or n not in nodes for n in edge):
            raise ValueError('unknown_endpoint')
    if len(set(edges)) != len(edges):
        raise ValueError('duplicate_edge')
    ordered = tuple(sorted(nodes))
    outgoing = {n: [] for n in ordered}
    incoming = {n: [] for n in ordered}
    for source, target in sorted(edges):
        outgoing[source].append(target)
        incoming[target].append(source)
    return ordered, outgoing, incoming


def document_groups(nodes, edges):
    ordered, outgoing, incoming = supplied_graph(nodes, edges)
    seen, finished = set(), []

    def finish_reverse(node):
        seen.add(node)
        for previous in incoming[node]:
            if previous not in seen:
                finish_reverse(previous)
        finished.append(node)  # Append only AFTER exploring descendants.

    for node in ordered:
        if node not in seen:
            finish_reverse(node)
    seen.clear()  # Separate traversal state for the second pass.
    found = []

    def gather_original(node, group):
        seen.add(node)
        group.append(node)
        for target in outgoing[node]:
            if target not in seen:
                gather_original(target, group)

    for node in reversed(finished):
        if node not in seen:
            group = []
            gather_original(node, group)
            found.append(tuple(sorted(group)))
    components = tuple(sorted(found))
    owner = {node: i for i, group in enumerate(components) for node in group}
    mapping = {node: owner[node] for node in ordered}
    condensed = tuple(sorted({(owner[u], owner[v]) for u, v in edges
                              if owner[u] != owner[v]}))
    cyclic = tuple(i for i, group in enumerate(components)
                   if len(group) > 1 or (group[0], group[0]) in edges)
    return {'components': components, 'mapping': mapping,
            'condensation_edges': condensed, 'cyclic_component_ids': cyclic}


def closure_reference(nodes, edges, reflexive=True):
    """Boolean matrix through-intermediate-vertex recurrence; no DFS calls."""
    order = tuple(sorted(nodes))
    matrix = [[(reflexive and u == v) or (u, v) in edges
               for v in order] for u in order]
    for k in range(len(order)):
        for i in range(len(order)):
            for j in range(len(order)):
                matrix[i][j] = matrix[i][j] or (matrix[i][k] and matrix[k][j])
    return order, matrix


def partition_reference(nodes, edges):
    """Mutual reachability equivalence classes, not traversal finishing order."""
    order, reachable = closure_reference(nodes, edges)
    classes, assigned = [], set()
    for i, node in enumerate(order):
        if node not in assigned:
            group = tuple(v for j, v in enumerate(order)
                          if reachable[i][j] and reachable[j][i])
            classes.append(group)
            assigned.update(group)
    groups = tuple(sorted(classes))
    group_of = {node: index for index, group in enumerate(groups) for node in group}
    quotient = tuple(sorted({(group_of[u], group_of[v]) for u, v in edges
                             if group_of[u] != group_of[v]}))
    return groups, quotient


def quotient_certificate(nodes, edges, result):
    """Check acyclicity and preservation of reachability after contraction."""
    count = len(result['components'])
    group_nodes = tuple(range(count))
    quotient = result['condensation_edges']
    _, positive_paths = closure_reference(group_nodes, quotient, reflexive=False)
    if any(positive_paths[i][i] for i in range(count)):
        return False
    original_order, original_paths = closure_reference(nodes, edges)
    _, group_paths = closure_reference(group_nodes, quotient)
    return all(original_paths[i][j] == group_paths[result['mapping'][u]][result['mapping'][v]]
               for i, u in enumerate(original_order) for j, v in enumerate(original_order))


def rejects(call, message):
    try:
        call()
    except ValueError as error:
        return str(error) == message
    return False


def run_example():
    nodes = tuple('ABCDEFGH')
    edges = (('A', 'B'), ('B', 'C'), ('C', 'A'), ('C', 'D'), ('B', 'D'),
             ('D', 'E'), ('E', 'D'), ('E', 'F'), ('F', 'F'), ('H', 'A'))
    before = (nodes, edges)
    main = document_groups(nodes, edges)
    reversed_edges = tuple((v, u) for u, v in edges)
    reversed_result = document_groups(nodes, reversed_edges)
    joined = document_groups(nodes, edges + (('F', 'B'),))
    one_way = document_groups(('A', 'B'), (('A', 'B'),))
    self_loop = document_groups(('A',), (('A', 'A'),))
    oracle_ok = certificate_ok = True
    graph_cases = 0
    for sample_nodes, possible in [
            (tuple('ABC'), tuple(product('ABC', repeat=2))),
            (tuple('ABCD'), tuple((u, v) for u in 'ABCD' for v in 'ABCD' if u != v))]:
        for flags in product((False, True), repeat=len(possible)):
            sample_edges = tuple(edge for edge, on in zip(possible, flags, strict=True) if on)
            actual = document_groups(sample_nodes, sample_edges)
            groups, quotient = partition_reference(sample_nodes, sample_edges)
            oracle_ok = oracle_ok and actual['components'] == groups
            oracle_ok = oracle_ok and actual['condensation_edges'] == quotient
            certificate_ok = certificate_ok and quotient_certificate(sample_nodes, sample_edges, actual)
            graph_cases += 1
    monotone = True
    addition_cases = 0
    for edge in product(nodes, repeat=2):
        if edge not in edges:
            extended = document_groups(nodes, edges + (edge,))
            monotone = monotone and all(
                extended['mapping'][u] == extended['mapping'][v]
                for group in main['components'] for u in group for v in group)
            addition_cases += 1
    rename = dict(zip(nodes, tuple('PONMLKJI'), strict=True))
    renamed = document_groups(tuple(rename[n] for n in reversed(nodes)),
                              tuple((rename[u], rename[v]) for u, v in reversed(edges)))
    restored = {frozenset(next(n for n in nodes if rename[n] == value) for value in group)
                for group in renamed['components']}
    node_errors = [(None, 'nodes_tuple'), ([], 'nodes_tuple'), ('ABC', 'nodes_tuple'),
                   ((True,), 'node_name'), ((1,), 'node_name'), (('',), 'node_name'),
                   (('a',), 'node_name'), ((' A',), 'node_name'), (('A/B',), 'node_name'),
                   (('ABCDEFGHI',), 'node_name'), (('A', 'A'), 'duplicate_node')]
    edge_errors = [(None, 'edges_tuple'), ([], 'edges_tuple'), (([],), 'edge_shape'),
                   ((('A',),), 'edge_shape'), ((('A', 'B', 'A'),), 'edge_shape'),
                   ((('A', 'UNKNOWN'),), 'unknown_endpoint'), ((('A', True),), 'unknown_endpoint'),
                   ((('A', 'B'), ('A', 'B')), 'duplicate_edge')]
    dense_edges = tuple(product(nodes, repeat=2))
    dense = document_groups(nodes, dense_edges)
    altered = document_groups(nodes, edges)
    altered['mapping']['A'] = 99
    altered['components'] = ()
    checks = {
        'manual_five_strong_components_include_isolated_G':
            main['components'] == (('A', 'B', 'C'), ('D', 'E'), ('F',), ('G',), ('H',)),
        'manual_cross_group_edges_coalesce_and_ids_are_not_topological_order':
            main['condensation_edges'] == ((0, 1), (1, 2), (4, 0))
            and main['mapping'] == {'A': 0, 'B': 0, 'C': 0, 'D': 1, 'E': 1, 'F': 2, 'G': 3, 'H': 4},
        'one_way_connection_does_not_merge_strong_components':
            one_way['components'] == (('A',), ('B',)) and one_way['cyclic_component_ids'] == (),
        'self_loop_is_cyclic_singleton_but_is_removed_from_condensation':
            self_loop['components'] == (('A',),) and self_loop['cyclic_component_ids'] == (0,)
            and self_loop['condensation_edges'] == () and main['cyclic_component_ids'] == (0, 1, 2),
        'reversing_all_edges_preserves_partition_and_reverses_quotient':
            reversed_result['components'] == main['components']
            and reversed_result['condensation_edges'] == tuple(sorted((v, u) for u, v in main['condensation_edges'])),
        'one_return_edge_merges_three_previously_separate_components':
            joined['components'] == (tuple('ABCDEF'), ('G',), ('H',))
            and joined['condensation_edges'] == ((2, 0),) and joined['cyclic_component_ids'] == (0,),
        'edge_addition_cannot_split_an_existing_strong_component': bool(monotone) and addition_cases == 54,
        'empty_and_edgeless_graphs_have_reflexive_singletons':
            document_groups((), ()) == {'components': (), 'mapping': {}, 'condensation_edges': (), 'cyclic_component_ids': ()}
            and document_groups(('C', 'A', 'B'), ())['components'] == (('A',), ('B',), ('C',)),
        'independent_boolean_closure_oracle_4608_graphs_one_family': bool(oracle_ok) and graph_cases == 4608,
        'condensation_is_acyclic_and_preserves_all_node_pair_reachability':
            bool(certificate_ok) and quotient_certificate(nodes, edges, main),
        'input_order_and_bijective_node_names_preserve_structural_groups':
            document_groups(tuple(reversed(nodes)), tuple(reversed(edges))) == main
            and restored == {frozenset(group) for group in main['components']},
        'node_collection_name_and_duplicate_contracts_reject':
            all(rejects(lambda value=value: document_groups(value, ()), error) for value, error in node_errors),
        'edge_collection_shape_endpoint_and_duplicate_contracts_reject':
            all(rejects(lambda value=value: document_groups(('A', 'B'), value), error) for value, error in edge_errors)
            and rejects(lambda: document_groups((), (('A', 'A'),)), 'unknown_endpoint'),
        'eight_nodes_and_sixty_four_distinct_edges_are_explicit_own_limits':
            dense['components'] == (nodes,) and dense['condensation_edges'] == ()
            and rejects(lambda: document_groups(tuple('ABCDEFGHI'), ()), 'nodes_tuple')
            and rejects(lambda: document_groups(nodes, dense_edges + (('A', 'A'),)), 'edges_tuple'),
        'input_preserved_and_mutating_one_result_cannot_change_another':
            (nodes, edges) == before and document_groups(nodes, edges) == main and altered != main,
    }
    assert len(checks) == 15 and all(type(v) is bool and v for v in checks.values()), checks
    return {'python': platform.python_version(), 'dependencies': 'Python standard library only',
            'scope': 'Bounded supplied directed document links; no crawl, text, ranking, semantic duplicates, source authority or SEO result',
            'results': {'nodes': nodes, 'edges': edges, 'main': main,
                        'with_return_edge_F_to_B': joined,
                        'oracle_graph_cases_inside_one_family': graph_cases,
                        'added_edge_cases_inside_one_family': addition_cases,
                        'limits': {'nodes': 8, 'distinct_directed_edges_including_self_loops': 64},
                        'networkx_executed': False, 'java_executed': False}, 'checks': checks}


if __name__ == '__main__':
    print(json.dumps(run_example(), ensure_ascii=False, indent=2))

مرجعِ مستقل، ماتریسِ بولیِ دسترسی را از یال‌ها می‌سازد؛ قطر را برای مسیرِ بدون یال روشن می‌کند و امکانِ عبور از هر گرهِ میانی را به‌نوبت اضافه می‌کند. دو عضو زمانی هم‌گروه‌اند که هر دو خانهٔ رفت و برگشت روشن باشند. این مسیر نه DFS دارد و نه ترتیبِ پایانِ الگوریتمِ اصلی را می‌خواند. برای گرافِ فشرده، جداگانه نبودِ مسیرِ بستهٔ مثبت و حفظِ دسترسیِ همهٔ زوج‌های اصلی بررسی می‌شود.

پانزده گروهِ نام‌دار گذشتند. مرجع روی تمامِ ۵۱۲ گرافِ سه‌گرهی با امکانِ خودحلقه و ۴۰۹۶ گرافِ چهارگرهیِ بدون خودحلقه مقایسه شد؛ مجموعِ ۴۶۰۸ گراف یک خانوادهٔ مرجع است. افزودنِ هر یک از ۵۴ یالِ غایبِ نمونه نیز در یک خانواده بررسی می‌کند که مؤلفهٔ قبلی شکسته نشود. تعدادِ حالت‌ها را گروهِ تازه یا سنجشِ سرعت و مقیاسِ وب نمی‌شماریم.

{
  "python": "3.14.5",
  "dependencies": "Python standard library only",
  "scope": "Bounded supplied directed document links; no crawl, text, ranking, semantic duplicates, source authority or SEO result",
  "results": {
    "nodes": [
      "A",
      "B",
      "C",
      "D",
      "E",
      "F",
      "G",
      "H"
    ],
    "edges": [
      [
        "A",
        "B"
      ],
      [
        "B",
        "C"
      ],
      [
        "C",
        "A"
      ],
      [
        "C",
        "D"
      ],
      [
        "B",
        "D"
      ],
      [
        "D",
        "E"
      ],
      [
        "E",
        "D"
      ],
      [
        "E",
        "F"
      ],
      [
        "F",
        "F"
      ],
      [
        "H",
        "A"
      ]
    ],
    "main": {
      "components": [
        [
          "A",
          "B",
          "C"
        ],
        [
          "D",
          "E"
        ],
        [
          "F"
        ],
        [
          "G"
        ],
        [
          "H"
        ]
      ],
      "mapping": {
        "A": 0,
        "B": 0,
        "C": 0,
        "D": 1,
        "E": 1,
        "F": 2,
        "G": 3,
        "H": 4
      },
      "condensation_edges": [
        [
          0,
          1
        ],
        [
          1,
          2
        ],
        [
          4,
          0
        ]
      ],
      "cyclic_component_ids": [
        0,
        1,
        2
      ]
    },
    "with_return_edge_F_to_B": {
      "components": [
        [
          "A",
          "B",
          "C",
          "D",
          "E",
          "F"
        ],
        [
          "G"
        ],
        [
          "H"
        ]
      ],
      "mapping": {
        "A": 0,
        "B": 0,
        "C": 0,
        "D": 0,
        "E": 0,
        "F": 0,
        "G": 1,
        "H": 2
      },
      "condensation_edges": [
        [
          2,
          0
        ]
      ],
      "cyclic_component_ids": [
        0
      ]
    },
    "oracle_graph_cases_inside_one_family": 4608,
    "added_edge_cases_inside_one_family": 54,
    "limits": {
      "nodes": 8,
      "distinct_directed_edges_including_self_loops": 64
    },
    "networkx_executed": false,
    "java_executed": false
  },
  "checks": {
    "manual_five_strong_components_include_isolated_G": true,
    "manual_cross_group_edges_coalesce_and_ids_are_not_topological_order": true,
    "one_way_connection_does_not_merge_strong_components": true,
    "self_loop_is_cyclic_singleton_but_is_removed_from_condensation": true,
    "reversing_all_edges_preserves_partition_and_reverses_quotient": true,
    "one_return_edge_merges_three_previously_separate_components": true,
    "edge_addition_cannot_split_an_existing_strong_component": true,
    "empty_and_edgeless_graphs_have_reflexive_singletons": true,
    "independent_boolean_closure_oracle_4608_graphs_one_family": true,
    "condensation_is_acyclic_and_preserves_all_node_pair_reachability": true,
    "input_order_and_bijective_node_names_preserve_structural_groups": true,
    "node_collection_name_and_duplicate_contracts_reject": true,
    "edge_collection_shape_endpoint_and_duplicate_contracts_reject": true,
    "eight_nodes_and_sixty_four_distinct_edges_are_explicit_own_limits": true,
    "input_preserved_and_mutating_one_result_cannot_change_another": true
  }
}

۵. چهار پرسش دربارهٔ گروه، چرخه و معنا

پاسخِ تمرین‌ها و مرزِ تفسیرِ گروه‌های سند
تصویر مفهومی: پاسخِ تمرین‌ها و مرزِ تفسیرِ گروه‌های سند؛ بدون مقیاس عددی و مستقل از نتایج اجرای کد.

پرسش اول: افزودنِ F به B چه می‌کند؟ پاسخ: اکنون مسیرِ بازگشت از زنجیرهٔ A تا F به گروهِ آغازین داریم؛ شش عضو در یک مؤلفه قرار می‌گیرند. G و H هنوز تک‌عضوی‌اند، چون مسیرِ بازگشت به H نداریم. شناسه‌های نمایش دوباره ساخته می‌شوند؛ نباید شاخصِ عددی را کلیدِ پایدارِ همیشگی فرض کرد.

پرسش دوم: آیا یالِ چهار به صفر خطای مرتب‌سازی است؟ پاسخ: خیر؛ گروه‌ها برای نمایش با نامِ عضوها مرتب‌اند. ترتیبِ توپولوژیک، محاسبه‌ای با قیدِ یال‌هاست و با این شاخص‌ها یکی نیست. خودِ گرافِ فشرده بدون چرخه است، نه اینکه همهٔ یال‌هایش از عددِ کوچک به بزرگ بروند.

پرسش سوم: F و G هر دو تک‌عضوی‌اند؛ چرا فقط F چرخه‌دار گزارش می‌شود؟ پاسخ: F خودحلقه دارد و G ندارد. هر دو با مسیرِ بدون یال به خودشان می‌رسند و مؤلفه‌اند، اما چرخهٔ مثبت نیاز به یال دارد. مؤلفهٔ بیش از یک عضو نیز چرخه دارد؛ این ملاک از شمارِ عضوهای گروه و خودحلقه جدا ثبت شده است.

پرسش چهارم: آیا اسنادِ هم‌گروه را یکی کنیم؟ پاسخ: از این محاسبه چنین مجوزی نداریم؛ برنامه محتوا، نسخه، مالکیت یا اعتبار را ندیده است. نتیجه فقط دربارهٔ همان گرافِ داده‌شده است. یک مجموعهٔ ناقصِ پیوند می‌تواند مسیرِ بازگشتی را از قلم بیندازد؛ درستیِ حساب، کامل‌بودنِ داده را تضمین نمی‌کند.

منابع در ۲۷ مهر ۱۴۰۵ خوانده شدند. فایلِ منبعِ نویسندگان در یک commit ثابت نگه داشته شده؛ زمانِ تغییرِ آن، تاریخِ انتشارِ اولیهٔ الگوریتم نیست. کتابِ همراه مربوط به ۲۰۱۱ و صفحهٔ API مربوط به مستندات NetworkX 3.7 است؛ Java و NetworkX اجرا نشده‌اند. این آموزشِ پایه با دادهٔ ساختگی، جای خزشِ واقعی، تحلیلِ متن یا ارزیابیِ سامانهٔ جست‌وجو را نمی‌گیرد.

منابع و مطالعهٔ بیشتر

بررسی منابع: ۲۷ مهر ۱۴۰۵. تحلیل‌ها و پیشنهادهای اجرایی، جمع‌بندی نویسنده‌اند.