فهم أقصر مشكلة في المسار

وتبحث مشكلة جميع الألوان أقصر مسافة بين كل زوج من الألفاظ في صورة مرجحة، وهي تحد أساسي في نظرية الرسم البياني مع الآثار المباشرة على تصميم الشبكات، وتدفق حركة المرور على الوجه الأمثل، وتحليل الشبكات الاجتماعية، واللوجستيات، وخلافا لأقصر المشاكل في المسارات، يتطلب حل برنامج دعم البرامج منابر محسوبة من كل منحرف إلى الآخرين، وهو ما لا يمتد إلى حد كبير.

Forvids-Warshall, a dynamic programming algorithm, works on dense graphs but runs in O(V3) time and cannot handle negative weight cycles.

مقارنة المقاييس المشتركة

ومن أجل تقدير خوارزمية جونسون، يساعد على تناقض أكثر المذيبات استخداما في نظام الأفضليات المعمم:

  • Floyd-Warshall - Simple to implement, uses a 2D distance spec, updates via triple cycles. Works on negative edges but not negative cycles. Impractical for graphs with thousands of vertices due to cubic time.
  • Repeated Dijkstra – Runs Dijkstra from each vertex. Fast on sparse graphs (]O(V E log V)] using Fibonacci heaps), but restricted to non-negative weights.
  • Bellman-Ford (repeated)] — Handles negative edges but runs in ]O(V2E), which is slower than both alternatives.
  • Johnson’s Algorithm] – Re weights the graph so that all edges become non-negative, then applies repeated Dijkstra. It yields O(V E + V2 log V][FLT:

How Johnson’s Algorithm Works

ويحول خوارزمية جونسون بذكاء رسماً يحتوي على حواف سلبية إلى رسمة ذات وزن غير مؤثر فحسب، ويحافظ على هيكل أقصر الطرق، ويعتمد هذا التحول على وظيفة ][ ذات قدرة ](FLT:1] مستمدة من حرف واحد من طراز بيلمان فورد، وبعد إعادة وزنه، يمكن استخدام خط الطول الأربع.

الخطوة 1: إضافة رقم المصدر الخارق

A new vertex s is added to the graph, connected to every existing vertex with an edge of weight 0. This extra node does not alter shortest path distances because any path that uses ]s can be appended without cost.

الخطوة 2: المهام المحتملة الحاسوبية مع بيلمان - فورد

(أ) لا توجد أي مسارات (بيلمان فورثم) من المصدر الخارق [(FLT:0)] .

الخطوة 3: إعادة وزن الخراف

Using the potentials h(v)], each edge (u, v) with original weight w(u, v)] is re weighted to:

w'(u, v) = w(u, v) + h(u) -- h(v)]

وهذا التحول يضمن أن كل وزن حافة مرجح غير متجانس، والدليل يعتمد على عدم المساواة في المثلث: لأن (h)(v) /(h(u) +(u, v) (من ناتج شركة بيلمانفورد)، وهو ما يلي:

الخطوة 4: إدارة ألغوريثم ديجكسترا من كل فرد من أفراد البرلمان

ومع إعادة وزن الرسم البياني الذي يحتوي على حواف غير مجهرية فقط، فإن خوارزمية ديجكسترا تدار مرة واحدة من كل منحرف، وكل منها يحسب أقصر مسافة إلى جميع الشعائر الأخرى، ثم تتحول المسافات الناتجة عن ذلك إلى أوزان حافة أصلية باستخدام الصيغة:

dist]original(u, v) = dist]]re weighted(u, v) - h(u) + h(v)

وهذه الخطوة الأخيرة تضمن دقة المسافات المبلغ عنها بالنسبة للرسوم البيانية الأصلية.

التعقيد وتحليل الأداء

([FLT])

ويمكن أن يؤدي استخدام غطاء فيبوناتشي إلى تقليص جزء ديجكسترا إلى O(V E + V)(2) ) ] [مصفوفة]] مُخَذَرة، وإن كانت الأثقال الثنائية في الممارسة العملية أبسط وأسرع من اللازم.

التطبيقات العملية

ويستخدم خوارزمية جونسون في مجالات قد تحمل فيها حواف الرسوم البيانية تكاليف سلبية، وتحتاج جميع المسافات القصيرة إلى أبعد حد، وتشمل الأمثلة على العالم الحقيقي ما يلي:

  • Network routing:] Internet service providers and telecommunications networks use distributed routing protocols that must adaptively calculate the cheapest pathrs between any two routers, even when link costs fluctuate or become negative (e.g., due to congestion or policy opponents).
  • Urban transportation planning:] Mapping and logistical companies (e.g., Google Maps, OpenStreetMap routing motors) compute shortest paths between many origin-destination couples for fleet optimization. Negative weights can model subsidies or time-based opponents.
  • Supply chain cost minimization:] In multi‐stage production networks, costs from one node to another might be negative (e.g., rebates).
  • Social network analysis:] Measuring closeness centrality or betweenness centrality requires all‐pair distances. Negative edges can represent “friendof-a-afriend” discount links or adversarial relationships.
  • Economic input‐output models:] Leontief models and flow analyses often involve negative coefficients; Johnson’s algorithm computes the net effect of propagating changes through an interconnected economy.

For further reading on the mathematical foundations, see Wikipedia’s detailed entry and the original paper by Donald B. Johnson (1977). A practical implementation in Python can be found on [-]NetworkX’s GitHub repository, al.

خاتمة

وتبرز خوارزمية جونسون حلاً واضحاً وعملياً لجميع أقصر مشكلة المسارات عندما تكون الأوزان السلبية على الحافة موجودة، إذ أنها تدمج قوة بيمان - فورد (لكشف الدورات السلبية والإمكانات الحاسوبية) مع سرعة استخدام " ديكسترا " (للرسوم البيانية غير المجدية)، تحقق أداء ممتازاً على شبكات التدفق المحتملة.

وعندما تواجه شركة جونسون مشكلة حقيقية في نظام الأفضليات المعمم حيث تكون الرسوم البيانية متفرقة وقد تحتوي على حواف سلبية، ينبغي أن يكون أول اعتبار لها، والضمانات النظرية التي تقدمها، والتنفيذ الواسع النطاق في المكتبات (مثلاً، [(NetworkX