forked from YaccConstructor/QuickGraph
-
-
Notifications
You must be signed in to change notification settings - Fork 71
DataSetGraph
Alexandre Rabérin edited this page Jun 11, 2020
·
1 revision
The DataSetGraph
is a directed graph of created from a DataSet
schema, where each table is a vertex and each table relation is an edge.
It is defined in the QuikGraph.Data module.
You can create a DataSetGraph
from any DataSet
by using the ToGraph
extension method.
using QuikGraph.Data;
DataSet dataSet = ...;
DataSetGraph graph = dataSet.ToGraph();
A very useful application of the DataSetGraph
is to compute the topological sort of the tables. The topological sort gives you the order in which you should fill tables (or reversely delete them).
DataSet dataSet = new (); // Get your data set
DataSetGraph graph = dataSet.ToGraph(); // Wraps the dataset into a DataSetGraph
foreach(DataTable table in graph.TopologicalSort()) // Applies a topological sort to the data set graph
{
// ...
}
QuikGraph has a bridge to Graphviz that has a specialized version for DataSetGraph
available through DataSetGraphvizAlgorithm
or more easily with extension ToGraphviz
.
DataSet dataSet = new ();
DataSetGraph graph = dataSet.ToGraph();
string dot = graph.ToGraphviz();
Which can produce results like this: