public static List <Node <string> > tablesByDependency(IRelationalData mgr, DataStructure.Compare order) { List <Node <string> > result = new List <Node <string> >(); List <Store> tables = mgr.tables(); List <Relation> foreignKeys = mgr.relations(); List <string> nodes = new List <string>(); foreach (Store table in tables) { nodes.Add(table.tableName); } List <Edge <string> > edges = new List <Edge <string> >(); foreach (Relation rec in foreignKeys) { edges.Add(new Edge <string>(rec.parent, rec.child)); } Vector <string> v = new Vector <string>(nodes, edges, equalStrings, order); if (v.nodes.Count == 0) { return(result); } foreach (Node <string> rec in v.nodes) { result.Add(rec); } return(result); }
public Vector(List <T> _data, List <Edge <T> > _edges, equals _equals, DataStructure.Compare _sort) { eq = _equals; initNodes(_data); edges = _edges; foreach (Edge <T> edge in edges) { int parentIdx = position(edge.parent); int childIdx = position(edge.child); if (nodes[parentIdx].depth >= nodes[childIdx].depth) { dipSubTree(childIdx, (short)(1 + nodes[parentIdx].depth)); } } DataStructure.Sort.selectionSort <Node <T> >(nodes, _sort, compareDepth); }