private void addEdges() {
    // remove old edges if available
    Iterator<String> e = edgeLabelMap.keySet().iterator();
    while (e.hasNext()) {
      graph.removeEdge(e.next());
    }
    edgeLabelMap.clear();

    boolean isDistance = measure.isDistance();
    Attribute id = exampleSet.getAttributes().getId();
    List<SortableEdge> sortableEdges = new LinkedList<SortableEdge>();
    for (int i = 0; i < exampleSet.size(); i++) {
      Example example = exampleSet.getExample(i);
      for (int j = i + 1; j < exampleSet.size(); j++) {
        Example comExample = exampleSet.getExample(j);
        if (isDistance)
          sortableEdges.add(
              new SortableEdge(
                  example.getValueAsString(id),
                  comExample.getValueAsString(id),
                  null,
                  measure.calculateDistance(example, comExample),
                  SortableEdge.DIRECTION_INCREASE));
        else
          sortableEdges.add(
              new SortableEdge(
                  example.getValueAsString(id),
                  comExample.getValueAsString(id),
                  null,
                  measure.calculateSimilarity(example, comExample),
                  SortableEdge.DIRECTION_DECREASE));
      }
    }

    Collections.sort(sortableEdges);

    int numberOfEdges = distanceSlider.getValue();
    int counter = 0;
    double minStrength = Double.POSITIVE_INFINITY;
    double maxStrength = Double.NEGATIVE_INFINITY;
    Map<String, Double> strengthMap = new HashMap<String, Double>();
    for (SortableEdge sortableEdge : sortableEdges) {
      if (counter > numberOfEdges) break;

      String idString = edgeFactory.create();
      graph.addEdge(
          idString,
          sortableEdge.getFirstVertex(),
          sortableEdge.getSecondVertex(),
          EdgeType.UNDIRECTED);
      edgeLabelMap.put(idString, Tools.formatIntegerIfPossible(sortableEdge.getEdgeValue()));

      double strength = sortableEdge.getEdgeValue();

      minStrength = Math.min(minStrength, strength);
      maxStrength = Math.max(maxStrength, strength);

      strengthMap.put(idString, strength);

      counter++;
    }

    for (Entry<String, Double> entry : strengthMap.entrySet()) {
      edgeStrengthMap.put(
          entry.getKey(), (entry.getValue() - minStrength) / (maxStrength - minStrength));
    }
  }