5. One "master input" node that connects to all input nodes, represented with the
inputPinsInfo array.
Edges are not created between inetrnal nodes and clocked part inputs.
*/
private Graph createConnectionsGraph() {
Graph graph = new Graph();
Iterator connectionIter = connections.iterator();
while (connectionIter.hasNext()) {
Connection connection = (Connection)connectionIter.next();
Integer part = new Integer(connection.getPartNumber());
int gatePinNumber = connection.getGatePinNumber();
switch (connection.getType()) {
case Connection.TO_INTERNAL:
if (isLegalFromPartEdge(connection, part))
graph.addEdge(part, getPinInfo(INTERNAL_PIN_TYPE, gatePinNumber));
break;
case Connection.FROM_INTERNAL:
if (isLegalToPartEdge(connection, part))
graph.addEdge(getPinInfo(INTERNAL_PIN_TYPE, gatePinNumber), part);
break;
case Connection.TO_OUTPUT:
if (isLegalFromPartEdge(connection, part))
graph.addEdge(part, getPinInfo(OUTPUT_PIN_TYPE, gatePinNumber));
break;
case Connection.FROM_INPUT:
if (isLegalToPartEdge(connection, part))
graph.addEdge(getPinInfo(INPUT_PIN_TYPE, gatePinNumber), part);
break;
case Connection.FROM_TRUE:
if (isLegalToPartEdge(connection, part))
graph.addEdge(TRUE_NODE_INFO, part);
break;
case Connection.FROM_FALSE:
if (isLegalToPartEdge(connection, part))
graph.addEdge(FALSE_NODE_INFO, part);
break;
case Connection.FROM_CLOCK:
if (isLegalToPartEdge(connection, part))
graph.addEdge(CLOCK_NODE_INFO, part);
break;
}
}
// connect the "master part" node to all the parts.
for (int i = 0; i < partsList.size(); i++)
graph.addEdge(partsList, new Integer(i));
// connect all output pins to the "master output" node
for (int i = 0; i < outputPinsInfo.length; i++)
graph.addEdge(outputPinsInfo[i], outputPinsInfo);
// connect the "master input" node to all input pins
for (int i = 0; i < inputPinsInfo.length; i++)
graph.addEdge(inputPinsInfo, inputPinsInfo[i]);
return graph;
}