Examples
Real-world examples demonstrating how to use Yog.FSharp for various graph problems.
Running Examples
All examples are literate F# scripts that you can run directly:
|
Or reference in your F# Interactive session:
#load "docs/examples/gps-navigation.fsx"
The examples use literate programming - documentation is embedded in the .fsx files using (** and *) comment blocks.
Pathfinding & Traversal
Example |
Description |
Demonstrates |
|---|---|---|
Find the fastest route between locations using heuristic-based search. |
A* algorithm, heuristics, route planning |
|
Find the fastest delivery route in a weighted road network. |
Dijkstra's algorithm, single-source distances |
|
Shortest paths with negative weights and negative cycle detection. |
Bellman-Ford, negative cycle detection |
|
Compute shortest distances between all pairs of cities in a network. |
All-pairs shortest paths, distance matrices |
|
Count all valid paths through a cave system with complex visit rules. |
Custom DFS, backtracking, state-space search |
Graph Properties & Algorithms
Example |
Description |
Demonstrates |
|---|---|---|
The classic problem that founded graph theory. |
Eulerian paths/circuits, degree analysis |
|
Determine the correct execution order for tasks with dependencies. |
Topological sorting on DAGs, cycle detection |
|
Alphabetically earliest execution order for tasks with multiple valid orderings. |
Lexicographical topological sort, stable resolution |
|
Find communities in a social network using strongly connected components. |
Tarjan's & Kosaraju's SCC algorithms |
|
Find the minimum cost to connect all buildings using Kruskal's algorithm. |
Minimum Spanning Trees (MST), cost optimization |
|
Identify the most important nodes using degree, closeness, betweenness, PageRank, and eigenvector centrality. |
All 5 centrality measures |
|
Find critical infrastructure whose failure disconnects the network. |
Tarjan's bridge-finding algorithm |
|
Find tightly-knit groups using the Bron-Kerbosch algorithm. |
Maximum clique, all maximal cliques, k-cliques |
|
Critical path analysis and transitive closure on a task dependency DAG. |
Longest path, transitive closure, topological sort |
Flow & Matching
Example |
Description |
Demonstrates |
|---|---|---|
Solve a bipartite matching problem using maximum flow algorithms. |
Edmonds-Karp, bipartite matching, network modeling |
|
Maximize throughput and identify bottlenecks in a computer network. |
Edmonds-Karp, Max-Flow Min-Cut Theorem |
|
Find the "natural" split point of a graph that disconnects it with minimum cost. |
Stoer-Wagner algorithm, network reliability |
|
Solve the stable marriage problem to match residents to hospitals. |
Gale-Shapley algorithm, stable matching |
Classic Graph Generators
Example |
Description |
Demonstrates |
|---|---|---|
Generate \(K_n\) graphs where every node connects to every other. |
|
|
Generate \(C_n\) graphs forming a single closed loop. |
|
|
Generate \(P_n\) graphs forming a linear chain. |
|
|
Generate \(S_n\) graphs with a central hub node. |
|
|
Generate \(W_n\) graphs by adding a hub to a cycle. |
|
|
Generate rectangular lattice meshes. |
|
|
Generate complete bipartite graphs \(K_{m,n}\). |
|
|
Generate \(n\) isolated nodes with no edges. |
|
|
Generate complete binary trees of a given depth. |
|
|
Generate the famous 10-node, 15-edge cubic graph. |
|
Stochastic Network Models
Example |
Description |
Demonstrates |
|---|---|---|
Random graphs where each edge exists with probability \(p\). |
|
|
Random graphs with exactly \(m\) edges added uniformly. |
|
|
Scale-free networks generated via preferential attachment. |
|
|
Small-world networks with high clustering and short paths. |
|
|
Uniformly random tree structure on \(n\) nodes. |
|
IO & Serialization
Example |
Description |
Demonstrates |
|---|---|---|
Export graphs to Graphviz DOT format for professional visualization. |
Yog.IO.Dot, visual customization, Graphviz |
|
Export graph data to JSON for web APIs and frontend visualization. |
Yog.IO.Json, indented serialization, data interchange |
|
Export and import graphs in GraphML format for Gephi, yEd, and Cytoscape. |
Yog.IO.GraphML, round-trip, custom attributes |
|
Export graphs to GDF format for Gephi and lightweight text-based interchange. |
Yog.IO.Gdf, column-based format, custom attributes |
Check the GitHub repository for the latest examples!