@Override
 public Graph<String, String> createGraph() {
   graph = new DirectedSparseGraph<String, String>();
   boolean[] allFilter = new boolean[rules.getNumberOfRules()];
   for (int i = 0; i < allFilter.length; i++) {
     allFilter[i] = true;
   }
   addRuleNodes(allFilter);
   return graph;
 }
  private boolean[] getFilter(
      AssociationRules rules, Item[] filter, int conjunctionMode, double minRatio) {
    boolean[] mapping = new boolean[rules.getNumberOfRules()];
    int counter = 0;
    for (AssociationRule rule : rules) {
      if (getCriterionValue(rule) >= getCriterionMinValue(minRatio)) {
        if (checkForItem(filter, rule, conjunctionMode)) {
          mapping[counter] = true;
        } else {
          mapping[counter] = false;
        }
      } else {
        mapping[counter] = false;
      }
      counter++;
    }

    return mapping;
  }
  private void addRuleNodes(boolean[] filter) {
    Iterator<String> e = edgeList.iterator();
    while (e.hasNext()) {
      graph.removeEdge(e.next());
    }

    Iterator<String> n = nodeList.iterator();
    while (n.hasNext()) {
      graph.removeVertex(n.next());
    }

    edgeList.clear();
    nodeList.clear();

    toolTipInfos.clear();
    asPremise.clear();
    asConclusion.clear();

    int ruleIndex = 1;
    for (int r = 0; r < rules.getNumberOfRules(); r++) {
      if (filter[r]) {
        AssociationRule rule = rules.getRule(r);

        // define conjunction node
        String conjunctionNode =
            "Rule "
                + ruleIndex
                + " ("
                + Tools.formatNumber(rule.getTotalSupport())
                + " / "
                + Tools.formatNumber(rule.getConfidence())
                + ")";
        toolTipInfos.put(
            conjunctionNode,
            "<html><b>Rule "
                + ruleIndex
                + "</b><br>"
                + SwingTools.addLinebreaks(
                    rule.toPremiseString() + " --> " + rule.toConclusionString())
                + "<br><b>Support:</b> "
                + rule.getTotalSupport()
                + "<br><b>Confidence:</b> "
                + rule.getConfidence()
                + "<br><b>Lift:</b> "
                + rule.getLift()
                + "<br><b>Gain:</b> "
                + rule.getGain()
                + "<br><b>Conviction:</b> "
                + rule.getConviction()
                + "<br><b>Laplace:</b> "
                + rule.getLaplace()
                + "<br><b>Ps:</b> "
                + rule.getPs()
                + "</html>");
        nodeList.add(conjunctionNode);

        // add premise nodes
        Iterator<Item> p = rule.getPremiseItems();
        while (p.hasNext()) {
          Item premiseItem = p.next();
          String edgeId = edgeFactory.create();
          edgeList.add(edgeId);
          nodeList.add(premiseItem.toString());
          graph.addEdge(edgeId, premiseItem.toString(), conjunctionNode);
          List<String> premiseList = asPremise.get(premiseItem.toString());
          if (premiseList == null) {
            premiseList = new LinkedList<String>();
            asPremise.put(premiseItem.toString(), premiseList);
          }
          premiseList.add("Rule " + ruleIndex);
        }

        // add conclusion nodes
        Iterator<Item> c = rule.getConclusionItems();
        while (c.hasNext()) {
          Item conclusionItem = c.next();
          String edgeId = edgeFactory.create();
          edgeList.add(edgeId);
          nodeList.add(conclusionItem.toString());
          graph.addEdge(edgeId, conjunctionNode, conclusionItem.toString());
          List<String> conclusionList = asConclusion.get(conclusionItem.toString());
          if (conclusionList == null) {
            conclusionList = new LinkedList<String>();
            asConclusion.put(conclusionItem.toString(), conclusionList);
          }
          conclusionList.add("Rule " + ruleIndex);
        }
      }
      ruleIndex++;
    }
  }