انتقل إلى المحتوى

مورد · دليل أو مقال

Kruskal's Algorithm

يقدّم خوارزمية Kruskal الجشعة لإيجاد الشجرة الممتدة الصغرى، التي تواصل إضافة أخف حافة تصل بين شجرتين منفصلتين.

تمت المراجعة

افتح المصدر الأصلي: Kruskal's Algorithm (يفتح الموقع الأصلي في علامة تبويب جديدة)

تدرّب على هذا الموضوعيفتح المحاور التدريبي بسؤال عن الرسوم البيانية.

أضِف إلى خريطة طريق

احتفظ بهذا المورد مع خريطة طريق تتبعها. يظهر موردًا إضافيًا خاصًا بك، فلا تتغير خطوات الخريطة ولا يُحتسب ضمن خطواتك المتتبَّعة.

لغة المحتوى الأصلي: الإنجليزية

Kruskal's algorithm is a minimum-spanning-tree algorithm which finds an edge of the least possible weight that connects any two trees in the forest. It is a greedy algorithm in graph theory as it finds a minimum spanning tree for a connected weighted graph adding increasing cost arcs at each step. This means it finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized. If the graph is not connected, then it finds a minimum spanning forest (a minimum spanning tree for each connected component). A demo for Kruskal's algorithm based on Euclidean distance. A minimum spanning tree (MST) or minimum weight spanning tree is a subset of the edges of a connected, edge-weighted (un)directed graph that connects all the vertices together, without any cycles and with the minimum possible total edge weight. That is, it is a spanning tree whose sum of edge weights is as small as possible. More generally, any edge-weighted undirected graph (not necessarily connected) has a minimum spanning forest, which is a union of the minimum spanning trees for its connected components.

نظرة عامة من PrepKit

كتب محررو PrepKit هذه النظرة العامة وراجعوها اعتمادًا على المستودع المصدر. وهي ليست نصًا من المورد نفسه.

مناسب لـ
لا يحدد المصدر مستوى
الشكل
مرجع

ما الذي يغطيه

  • النمو الجشع حافةً بعد حافة في Kruskal، والغابة الممتدة الصغرى التي تُرجعها لرسم بياني غير متصل
  • تعريف الشجرة الممتدة الصغرى، مع شكل يبيّن أن الرسم البياني قد تكون له أكثر من شجرة واحدة
  • عروض متحركة، أحدها قائم على المسافة الإقليدية

كيف تستخدمه

نصيحة دراسية من PrepKit، وليست ادعاءً من المصدر.

نفّذ Kruskal بحواف مرتبة وunion-find، وتأكّد من أن اختلاف ترتيب الحواف المتساوية الوزن يعطي أشجارًا مختلفة متساوية الوزن.

النطاق والقيود

تعريفات ورسوم متحركة في معظمه: لا شرح لـunion-find ولا تعقيد ولا شرح نصي خطوة بخطوة.

الوصول والشكل

ملف README مجاني بالإنجليزية على GitHub في مستودع trekhleb/javascript-algorithms المرخّص بموجب MIT.

راجعه PrepKit في 02‏/10‏/2026. إيداع مصدر المورد: 85293e3e2b88

أدلة هذه النظرة العامة
  • src/algorithms/graph/kruskal/README.md

صفحات تتضمن هذا العنصر

اشترك في النشرة البريدية من PrepKit

اختيارية. لا تحتاج إليها لاستخدام PrepKit.

كيف نتعامل مع بريدك الإلكتروني