![]() |
VOOZH | about |
dotnet add package QuickGraph.NETStandard --version 4.0.0
NuGet\Install-Package QuickGraph.NETStandard -Version 4.0.0
<PackageReference Include="QuickGraph.NETStandard" Version="4.0.0" />
<PackageVersion Include="QuickGraph.NETStandard" Version="4.0.0" />Directory.Packages.props
<PackageReference Include="QuickGraph.NETStandard" />Project file
paket add QuickGraph.NETStandard --version 4.0.0
#r "nuget: QuickGraph.NETStandard, 4.0.0"
#:package QuickGraph.NETStandard@4.0.0
#addin nuget:?package=QuickGraph.NETStandard&version=4.0.0Install as a Cake Addin
#tool nuget:?package=QuickGraph.NETStandard&version=4.0.0Install as a Cake Tool
A comprehensive collection of examples demonstrating the capabilities of the QuickGraph.NETStandard library.
QuickGraph.NETStandard is a powerful graph data structure and algorithm library for .NET. These examples showcase various graph types, algorithms, visualization techniques, and real-world applications.
To use the visualization features, install Graphviz:
Windows:
Linux:
sudo apt-get install graphviz # Ubuntu/Debian
sudo yum install graphviz # Fedora/RHEL
macOS:
brew install graphviz
cd Examples
dotnet run
A menu-driven interface will guide you through all available examples.
Learn fundamental graph data structures:
AddVertex(), AddEdge(), OutEdges(), InDegree()AdjacentEdges(), AdjacentDegree(), connectivity checksOutEdges(), InEdges(), degree centralityMaster essential graph algorithms:
Create professional graph visualizations:
Apply graph theory to practical problems:
Examples/
??? Program.cs # Main menu application
??? BasicGraphs/
? ??? SimpleDirectedGraphExample.cs
? ??? UndirectedGraphExample.cs
? ??? BidirectionalGraphExample.cs
? ??? CustomEdgeTypesExample.cs
??? Algorithms/
? ??? ShortestPathExample.cs
? ??? BreadthFirstSearchExample.cs
? ??? DepthFirstSearchExample.cs
? ??? TopologicalSortExample.cs
? ??? StronglyConnectedComponentsExample.cs
? ??? MinimumSpanningTreeExample.cs
? ??? MaximumFlowExample.cs
? ??? CycleDetectionExample.cs
??? Visualization/
? ??? BasicVisualizationExample.cs
? ??? StyledVisualizationExample.cs
? ??? HierarchicalLayoutExample.cs
??? RealWorldScenarios/
??? SocialNetworkExample.cs
??? RoutePlanningExample.cs
??? TaskDependencyExample.cs
??? NetworkTopologyExample.cs
| Type | Description | When to Use |
|---|---|---|
AdjacencyGraph<TVertex, TEdge> |
Directed graph | One-way relationships, dependencies |
UndirectedGraph<TVertex, TEdge> |
Undirected graph | Symmetric relationships, networks |
BidirectionalGraph<TVertex, TEdge> |
Directed with reverse lookup | Need both in/out edges efficiently |
// Create graph
var graph = new AdjacencyGraph<string, Edge<string>>();
// Add vertices
graph.AddVertex("A");
graph.AddVertexRange(new[] { "B", "C", "D" });
// Add edges
graph.AddEdge(new Edge<string>("A", "B"));
graph.AddVerticesAndEdge(new Edge<string>("B", "C")); // Adds vertices if needed
// Query
int vertexCount = graph.VertexCount;
int edgeCount = graph.EdgeCount;
bool hasEdge = graph.ContainsEdge("A", "B");
int outDegree = graph.OutDegree("A");
IEnumerable<Edge<string>> edges = graph.OutEdges("A");
// Algorithms
var shortestPath = graph.ShortestPathsDijkstra(costFunc, "start");
var topologicalOrder = graph.TopologicalSort();
var components = graph.StronglyConnectedComponents(out var componentMap);
public class WeightedEdge : Edge<string>
{
public double Weight { get; set; }
public WeightedEdge(string source, string target, double weight)
: base(source, target)
{
Weight = weight;
}
}
var graph = new AdjacencyGraph<string, WeightedEdge>();
graph.AddVerticesAndEdge(new WeightedEdge("A", "B", 5.0));
| Algorithm | Time Complexity | Space Complexity |
|---|---|---|
| BFS | O(V + E) | O(V) |
| DFS | O(V + E) | O(V) |
| Dijkstra | O((V + E) log V) | O(V) |
| Topological Sort | O(V + E) | O(V) |
| Kruskal's MST | O(E log V) | O(V) |
| Edmonds-Karp | O(V � E�) | O(V + E) |
| Strongly Connected Components | O(V + E) | O(V) |
All visualization examples create two files:
.dot file - Text format that can be edited or processed.png file - Visual representation (requires Graphviz)Without Graphviz: Copy the DOT content to https://dreampuf.github.io/GraphvizOnline/
var graph = new AdjacencyGraph<string, Edge<string>>();
var weights = new Dictionary<Edge<string>, double>();
// Add weighted edges
void AddWeightedEdge(string from, string to, double weight) {
var edge = new Edge<string>(from, to);
graph.AddVerticesAndEdge(edge);
weights[edge] = weight;
}
// Find shortest path
Func<Edge<string>, double> costFunc = e => weights[e];
var tryGetPath = graph.ShortestPathsDijkstra(costFunc, "start");
if (tryGetPath("end", out var path)) {
// Process path
}
var visited = new HashSet<string>();
var dfs = new DepthFirstSearchAlgorithm<string, Edge<string>>(graph);
dfs.DiscoverVertex += vertex => {
visited.Add(vertex);
Console.WriteLine($"Discovered: {vertex}");
};
dfs.FinishVertex += vertex => {
Console.WriteLine($"Finished: {vertex}");
};
dfs.Compute("start");
var viz = new GraphvizAlgorithm<string, Edge<string>>(graph);
viz.FormatVertex += (sender, args) => {
args.VertexFormatter.Label = args.Vertex;
args.VertexFormatter.Shape = GraphvizVertexShape.Box;
args.VertexFormatter.FillColor = GraphvizColor.LightBlue;
args.VertexFormatter.Style = GraphvizVertexStyle.Filled;
};
viz.Generate(new FileDotEngine(), "output_file");
Choose the Right Graph Type
AdjacencyGraph for directed relationshipsUndirectedGraph for symmetric relationshipsBidirectionalGraph when you need efficient reverse lookupsMemory Considerations
Performance
Visualization
Error Handling
Feel free to add more examples or improve existing ones! Common additions might include:
These examples are part of the QuickGraph.NETStandard project.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 netstandard2.1 is compatible. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on QuickGraph.NETStandard:
| Package | Downloads |
|---|---|
|
GraphSharp_Unofficial_NineTailLabs
Graph layout framework and control. This fork is based on https://graphsharp.codeplex.com/. This is not an official release. |
|
|
AgentFire.Lifetime.Modules
Provides a way for an app to use module-based (Start/Stop) singleton instances. |
|
|
HorizonReports.Api
Horizon Reports Api for use from plugin projects. |
|
|
Taipan
Concurrency issues detection library |
|
|
HorizonReports.Core
Horizon Reports Core Support Libraries |
Showing the top 1 popular GitHub repositories that depend on QuickGraph.NETStandard:
| Repository | Stars |
|---|---|
|
tylercamp/palcalc
Comprehensive breeding solver for Palworld
|
- Added interactive menu and real-world, algorithm, and visualization demos
- Major documentation rewrite: README, quick start, architecture, contributing, changelog, marketing
- Updated solution and csproj for .NET Standard 2.1 and VS 2022+