001 // GraphLab Project: http://graphlab.sharif.edu 002 // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology 003 // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ 004 005 package graphlab.plugins.main.select; 006 007 import graphlab.graph.graph.EdgeModel; 008 import graphlab.graph.graph.GraphModel; 009 import graphlab.graph.graph.VertexModel; 010 import graphlab.plugins.commonplugin.undo.UndoableActionOccuredData; 011 import graphlab.plugins.main.GraphData; 012 013 import java.util.HashSet; 014 import java.util.Vector; 015 016 /** 017 * @author Azin Azadi 018 */ 019 public class MakeSelectionCompleteGraph extends MakeSelectionComplementGraph { 020 public String getName() { 021 return "Make Selection Complete"; 022 } 023 024 public String getDescription() { 025 return "Make the selected subgraph a complete graph"; 026 } 027 028 public void action(GraphData gd) { 029 if (gd.select.isSelectionEmpty()) 030 return; 031 HashSet<VertexModel> V = gd.select.getSelectedVertices(); 032 //add undo data 033 UndoableActionOccuredData uaod = new UndoableActionOccuredData(this); 034 fillUndoEdges(uaod.properties, gd, "old edges"); 035 036 GraphModel G = gd.getGraph(); 037 038 for (VertexModel v1 : V) { 039 for (VertexModel v2 : V) { 040 // if (v1.getId() < v2.getId()) { 041 // System.out.println(v1+","+v2); 042 G.insertEdge(new EdgeModel(v1, v2)); 043 // } 044 } 045 } 046 047 Vector<EdgeModel> ed = fillUndoEdges(uaod.properties, gd, "new edges"); 048 gd.select.setSelectedEdges(ed); 049 gd.core.addUndoData(uaod); 050 } 051 052 protected void doEdgeOperation(GraphModel g, HashSet<VertexModel> v) { 053 054 } 055 }