Graph graph = createConnectionsGraph();
// runs the topological sort, starting from the "master parts" node,
// which connects to all the parts. This will also check for circles.
Object[] topologicalOrder = graph.topologicalSort(partsList);
if (graph.hasCircle())
throw new HDLException("This chip has a circle in its parts connections");
// create the partsOrder array, by taking from the topologicalOrder