Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any graph data structure implemented for C#

I tried to find a graph data structure to reuse in C# without any success. Of course, I can borrow from data structure books but I want it to be more commercially practical(?) Also I would appreciate if you can tell me what the best way of implementing a graph is. Thanks

like image 448
Tae-Sung Shin Avatar asked Sep 23 '11 17:09

Tae-Sung Shin


People also ask

What is graph in data structure using C?

Data Structure - Graph Data Structure A graph is a pictorial representation of a set of objects where some pairs of objects are connected by links. The interconnected objects are represented by points termed as vertices, and the links that connect the vertices are called edges.

Which data structure is used to implement graphs?

A graph can be represented by one of three data structures: an adjacency matrix, an adjacency list, or an adjacency set. An adjacency matrix is similar to a table with rows and columns.

Does C# have a graph data structure?

A Graph is a data structure that contains a finite number of vertices (or nodes) and a finite set of edges connecting the vertices. In the above diagram, circles represent vertices, and lines represent edges connecting those vertices.


3 Answers

QuickGraph

QuickGraph is a graph library for .NET that is inspired by Boost Graph Library.

QuickGraph provides generic directed/undirected graph datastructures and algorithms for .Net 2.0 and up. QuickGraph comes with algorithms such as depth first seach, breath first search, A* search, shortest path, k-shortest path, maximum flow, minimum spanning tree, least common ancestors, etc... QuickGraph supports MSAGL, GLEE, and Graphviz to render the graphs, serialization to GraphML, etc...


There are several ways to build graphs. The C++ Boost Graph Library (BGL) would be your best reference. It implements both adjacency-list, adjacency-matrix and edge-list graphs. Look here for details.

like image 107
Lior Kogan Avatar answered Oct 07 '22 18:10

Lior Kogan


There is actually a fairly old article in MSDN that covers graph creation in C#, An Extensive Examination of Data Structures Using C# 2.0. Despite its age, it still addresses your question as long as you don't mind creating your own graph class(es).

like image 44
Michael Goldshteyn Avatar answered Oct 07 '22 19:10

Michael Goldshteyn


Under active development, there is https://www.nuget.org/packages/QuikGraph You can view source code on GitHub https://github.com/KeRNeLith/QuikGraph and also read the wiki https://github.com/KeRNeLith/QuikGraph/wiki

like image 21
TomDane Avatar answered Oct 07 '22 19:10

TomDane