@Override
  public boolean removeNode(V n) {
    boolean b = super.removeNode(n);
    if (n instanceof NodeView) {
      graph.removeVertex(n);
    }

    //		else if (n instanceof YConnectionView) {
    //			YConnectionView a = (YConnectionView) n;
    //
    //			// FIXME does the cast work?
    //			graph.removeEdge((E) a);
    //		}

    return b;
  }
  void reductioncover() {
    graphcreationcover();
    System.out.println("Enter the value of k and r for star packing in the graph");
    Scanner s = new Scanner(System.in);
    int k = Integer.parseInt(s.nextLine());
    int r = Integer.parseInt(s.nextLine());
    int i = 0;
    for (i = 1; i <= v; i++) {
      int x;

      x = k + r;

      int d;
      d = g.degree((i));
      if (d >= x) {
        g.removeVertex(i);

        k = k - 1;
        System.out.println("Graph after the deleting the vertex" + i + "is");
        System.out.println(g.toString());
      }
    }
    // System.out.println(g.toString());
  }
示例#3
0
 @Override
 public void keyTyped(KeyEvent event) {
   char keyChar = event.getKeyChar();
   if (keyChar == KeyEvent.VK_DELETE) {
     Set<V> verticesToRemove = new HashSet<V>();
     Set<V> picked = pickedVertexState.getPicked();
     for (V vertex : picked) {
       if (vertex instanceof VertexGroup<?>) {
         verticesToRemove.addAll(((VertexGroup<V>) vertex).getVertexGroupMembers());
       } else {
         verticesToRemove.add(vertex);
       }
     }
     for (V v : verticesToRemove) {
       System.out.println("\nremove vertex: " + v);
       pickedVertexState.pick(v, false);
       if (v instanceof AbstractNubisaveComponent) {
         ((AbstractNubisaveComponent) v).deactivate();
         ((AbstractNubisaveComponent) v).remove();
       }
       graph.removeVertex(v);
     }
   }
 }