private void addExecutionVertices(
      Map<ManagementGroupVertex, SWTGroupVertex> groupMap,
      ManagementGraph managementGraph,
      GraphVisualizationData visualizationData) {

    ManagementGraphIterator iterator = new ManagementGraphIterator(managementGraph, true);
    final Map<ManagementVertex, SWTVertex> vertexMap = new HashMap<ManagementVertex, SWTVertex>();
    final Map<ManagementGate, SWTGate> gateMap = new HashMap<ManagementGate, SWTGate>();

    while (iterator.hasNext()) {

      final ManagementVertex mv = iterator.next();
      final SWTGroupVertex parent = groupMap.get(mv.getGroupVertex());

      final SWTVertex visualVertex = new SWTVertex(parent, mv);
      vertexMap.put(mv, visualVertex);

      for (int i = 0; i < mv.getNumberOfOutputGates(); i++) {
        final ManagementGate outputGate = mv.getOutputGate(i);
        final SWTGate visualGate = new SWTGate(visualVertex, outputGate);
        gateMap.put(outputGate, visualGate);
      }

      for (int i = 0; i < mv.getNumberOfInputGates(); i++) {
        final ManagementGate inputGate = mv.getInputGate(i);
        final SWTGate visualGate = new SWTGate(visualVertex, inputGate);
        gateMap.put(inputGate, visualGate);
      }
    }

    iterator = new ManagementGraphIterator(managementGraph, true);

    // Setup connections
    while (iterator.hasNext()) {

      final ManagementVertex source = iterator.next();
      final SWTVertex visualSource = vertexMap.get(source);

      for (int i = 0; i < source.getNumberOfOutputGates(); i++) {

        final ManagementGate sourceGate = source.getOutputGate(i);
        final SWTGate visualSourceGate = gateMap.get(sourceGate);

        for (int j = 0; j < sourceGate.getNumberOfForwardEdges(); j++) {

          final ManagementEdge forwardEdge = sourceGate.getForwardEdge(j);
          final SWTVertex visualTarget = vertexMap.get(forwardEdge.getTarget().getVertex());
          final SWTGate visualTargetGate = gateMap.get(forwardEdge.getTarget());

          visualSource.connectTo(visualTarget);
          visualSourceGate.connectTo(visualTargetGate);
        }
      }
    }
  }
  private static void addExecutionVertices(
      Map<ExecutionGroupVertex, ManagementGroupVertex> groupMap, ExecutionGraph executionGraph) {

    ExecutionGraphIterator iterator = new ExecutionGraphIterator(executionGraph, true);
    final Map<ExecutionVertex, ManagementVertex> vertexMap =
        new HashMap<ExecutionVertex, ManagementVertex>();
    final Map<ExecutionGate, ManagementGate> gateMap = new HashMap<ExecutionGate, ManagementGate>();

    while (iterator.hasNext()) {

      final ExecutionVertex ev = iterator.next();
      final ManagementGroupVertex parent = groupMap.get(ev.getGroupVertex());

      final AbstractInstance instance = ev.getAllocatedResource().getInstance();
      final ManagementVertex managementVertex =
          new ManagementVertex(
              parent,
              ev.getID().toManagementVertexID(),
              (instance.getInstanceConnectionInfo() != null)
                  ? instance.getInstanceConnectionInfo().toString()
                  : instance.toString(),
              instance.getType().toString(),
              ev.getIndexInVertexGroup());
      managementVertex.setExecutionState(ev.getExecutionState());
      vertexMap.put(ev, managementVertex);

      for (int i = 0; i < ev.getNumberOfOutputGates(); i++) {
        final ExecutionGate outputGate = ev.getOutputGate(i);
        final ManagementGate managementGate =
            new ManagementGate(managementVertex, new ManagementGateID(), i, false);
        gateMap.put(outputGate, managementGate);
      }

      for (int i = 0; i < ev.getNumberOfInputGates(); i++) {
        final ExecutionGate inputGate = ev.getInputGate(i);
        final ManagementGate managementGate =
            new ManagementGate(managementVertex, new ManagementGateID(), i, true);
        gateMap.put(inputGate, managementGate);
      }
    }

    iterator = new ExecutionGraphIterator(executionGraph, true);

    // Setup connections
    while (iterator.hasNext()) {

      final ExecutionVertex source = iterator.next();

      for (int i = 0; i < source.getNumberOfOutputGates(); i++) {

        final ExecutionGate outputGate = source.getOutputGate(i);
        final ManagementGate manangementOutputGate = gateMap.get(outputGate);
        final ChannelType channelType = outputGate.getChannelType();

        for (int j = 0; j < outputGate.getNumberOfEdges(); j++) {

          final ExecutionEdge outputChannel = outputGate.getEdge(j);

          final ManagementGate managementInputGate = gateMap.get(outputChannel.getInputGate());

          final ManagementEdgeID sourceEdgeID =
              new ManagementEdgeID(outputChannel.getOutputChannelID());
          final ManagementEdgeID targetEdgeID =
              new ManagementEdgeID(outputChannel.getInputChannelID());
          new ManagementEdge(
              sourceEdgeID,
              targetEdgeID,
              manangementOutputGate,
              j,
              managementInputGate,
              outputChannel.getInputGateIndex(),
              channelType);
        }
      }
    }
  }