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.samples.extensions;
006    
007    import graphlab.graph.graph.EdgeModel;
008    import graphlab.graph.graph.GraphModel;
009    import graphlab.graph.graph.VertexModel;
010    import graphlab.plugins.main.GraphData;
011    import graphlab.plugins.main.extension.GraphActionExtension;
012    
013    import java.util.HashSet;
014    
015    public class CompleteSelectionAction implements GraphActionExtension {
016    
017        public void action(GraphData graphData) {
018            HashSet<VertexModel> sel = graphData.select.getSelectedVertices();
019            GraphModel g = graphData.getGraph();
020            for (VertexModel v1 : sel) {
021                for (VertexModel v2 : sel) {
022                    EdgeModel e = new EdgeModel(v1, v2);
023                    g.insertEdge(e);
024                }
025            }
026        }
027    
028        public String getName() {
029            return "complete selection";
030        }
031    
032        public String getDescription() {
033            return "Makes the selected subgraph a complete subgraph";
034        }
035    }