Algorithmes de graphe

Explorez les algorithmes qui résolvent des problèmes complexes sur des structures de données connectées. Maîtrisez le parcours de graphe avec BFS et DFS, trouvez les chemins les plus courts en utilisant les algorithmes de Dijkstra et Bellman-Ford, et calculez les arbres couvrants minimaux avec les algorithmes de Kruskal et Prim. Appliquez ces concepts à des problèmes du monde réel comme la navigation GPS, les réseaux sociaux et le routage réseau.

13 algorithmes

Parcours en largeur (BFS)

Intermediate

Explore un graphe niveau par niveau, visitant tous les sommets à la profondeur actuelle avant d'aller plus profondément. Utilise une file d'attente et est idéal pour trouver les chemins les plus courts dans les graphes non pondérés. Les applications incluent la résolution de labyrinthes, l'analyse de réseaux sociaux et la recherche de connexions entre nœuds.

O(V + E)
O(V)
graphtraversal
Start Learning

Parcours en profondeur (DFS)

Intermediate

Explore un graphe en allant aussi profondément que possible le long de chaque chemin avant de revenir en arrière. Implémenté à l'aide d'une pile ou de la récursion, ce qui le rend naturel pour les problèmes récursifs. Utilisé pour la recherche de chemins, la détection de cycles, le tri topologique et la génération de labyrinthes.

O(V + E)
O(V)
graphtraversal
Start Learning

Algorithme de Dijkstra

Advanced

Trouve les chemins les plus courts d'un sommet source unique vers tous les autres sommets dans un graphe pondéré. Alimente les systèmes de navigation GPS et les protocoles de routage réseau. Fonctionne efficacement avec des poids d'arêtes non négatifs en utilisant une approche gloutonne avec une file de priorité.

O((V + E) log V)
O(V)
graphshortest-path
Start Learning

A* Search Algorithm

Advanced

A best-first search algorithm that finds the shortest path using heuristics. Combines Dijkstra's algorithm and greedy best-first search using f(n) = g(n) + h(n). Widely used in games, robotics, and GPS navigation for efficient pathfinding.

O(E)
O(V)
graphpathfinding
Start Learning

Kruskal's Algorithm

Advanced

Finds the Minimum Spanning Tree (MST) of a weighted undirected graph. Uses a greedy approach by sorting edges by weight and adding them if they don't create a cycle. Employs Union-Find for efficient cycle detection. Essential for network design and clustering.

O(E log E)
O(V)
graphmst
Start Learning

Prim's Algorithm

Intermediate

Finds the Minimum Spanning Tree (MST) by growing a tree from a starting vertex. Always adds the minimum weight edge connecting a vertex in the tree to one outside. Uses a priority queue for efficient edge selection. Ideal for dense graphs.

O(E log V)
O(V)
graphmst
Start Learning

Topological Sort

Intermediate

Orders vertices of a Directed Acyclic Graph (DAG) such that for every edge u→v, u comes before v. Uses DFS-based approach. Essential for dependency resolution, build systems, and course scheduling.

O(V + E)
O(V)
graphdag
Start Learning

PageRank

Advanced

Google's algorithm for ranking web pages by link structure. Computes importance scores iteratively.

O(iterations Ă— (V + E))
O(V)
graphranking
Start Learning

Cycle Detection (Floyd's Algorithm)

Intermediate

Also known as the 'tortoise and hare' algorithm, this elegant technique detects cycles in linked lists or sequences using O(1) space. Uses two pointers moving at different speeds—if there's a cycle, they will eventually meet. Essential for detecting infinite loops, analyzing graph structures, and validating data integrity.

O(V + E)
O(V)
graphdfs
Start Learning

Bellman-Ford Algorithm

Advanced

Single-source shortest path algorithm that handles negative weights and detects negative cycles. Relaxes all edges V-1 times to guarantee correct distances even with negative weights. Essential for currency arbitrage detection, network routing with varied costs, and situations where Dijkstra's algorithm fails. Trades speed for flexibility.

O(V Ă— E)
O(V)
graphshortest-path
Start Learning

Floyd-Warshall Algorithm

Advanced

All-pairs shortest path algorithm that computes distances between every pair of vertices in O(VÂł) time. Uses dynamic programming with elegant three-line core logic. Handles negative weights and provides transitive closure. Ideal for dense graphs, network analysis, and when all pairwise distances are needed.

O(VÂł)
O(V²)
graphall-pairs-shortest-paths
Start Learning

Kruskal's MST Algorithm

Intermediate

Greedy algorithm that builds a minimum spanning tree by adding edges in order of increasing weight, using union-find to avoid cycles. Efficient for sparse graphs with time complexity O(E log E). Applications include network design, clustering, approximation algorithms, and understanding greedy correctness proofs.

O(E log E)
O(V)
graphminimum-spanning-tree
Start Learning

Prim's MST Algorithm

Intermediate

Greedy algorithm that grows a minimum spanning tree by repeatedly adding the cheapest edge connecting the tree to a new vertex. Uses a priority queue for efficiency with O(E log V) time. Preferred for dense graphs and real-time applications like network broadcasting and circuit design.

O(E log V)
O(V)
graphminimum-spanning-tree
Start Learning

đź’ˇ Conseil d'apprentissage

Commencez par les algorithmes de niveau débutant pour construire vos bases, puis progressez vers les sujets intermédiaires et avancés. Chaque algorithme comprend des visualisations interactives, une analyse de complexité et des exemples de code dans plusieurs langages.