Package org.gephi.graph.api

Examples of org.gephi.graph.api.GraphModel


@ServiceProvider(service = WorkspacePersistenceProvider.class, position = 15000)
public class AttributeRowPersistenceProvider implements WorkspacePersistenceProvider {

    public void writeXML(XMLStreamWriter writer, Workspace workspace) {
        AttributeModel model = workspace.getLookup().lookup(AttributeModel.class);
        GraphModel graphModel = workspace.getLookup().lookup(GraphModel.class);
        AttributeRowSerializer serializer = new AttributeRowSerializer();
        if (model != null && graphModel != null && model instanceof AbstractAttributeModel) {
            try {
                serializer.writeRows(writer, graphModel);
            } catch (XMLStreamException ex) {
View Full Code Here


        }
    }

    public void readXML(XMLStreamReader reader, Workspace workspace) {
        AttributeModel model = workspace.getLookup().lookup(AttributeModel.class);
        GraphModel graphModel = workspace.getLookup().lookup(GraphModel.class);
        AttributeRowSerializer serializer = new AttributeRowSerializer();
        if (model != null && graphModel != null && model instanceof AbstractAttributeModel) {
            try {
                serializer.readRows(reader, graphModel, (AbstractAttributeModel) model);
            } catch (XMLStreamException ex) {
View Full Code Here

     * cleared because the previous preview graph is forgotten.
     *
     * @see PreviewController#buildGraph()
     */
    public void buildGraph() {
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();
        model.clearSupervisors();

        graphModel.getGraph().readLock();

        if (graphModel.isUndirected()) {
            previewGraph = factory.createPreviewGraph(model, graphModel.getHierarchicalUndirectedGraphVisible());
        } else if (graphModel.isDirected()) {
            previewGraph = factory.createPreviewGraph(model, graphModel.getHierarchicalDirectedGraphVisible());
        } else {
            previewGraph = factory.createPreviewGraph(model, graphModel.getHierarchicalMixedGraphVisible());
        }

        graphModel.getGraph().readUnlockAll();

        model.setUpdateFlag(true);
    }
View Full Code Here

        currentPreset = new DefaultPreset();
        applyPreset(currentPreset);
    }

    public void select(Workspace workspace) {
        GraphModel graphModel = workspace.getLookup().lookup(GraphModel.class);
        graphModel.addGraphListener(this);
    }
View Full Code Here

        GraphModel graphModel = workspace.getLookup().lookup(GraphModel.class);
        graphModel.addGraphListener(this);
    }

    public void unselect(Workspace workspace) {
        GraphModel graphModel = workspace.getLookup().lookup(GraphModel.class);
        graphModel.removeGraphListener(this);
    }
View Full Code Here

                statement.executeUpdate("create table nodes (id string, label string)");
                statement.executeUpdate("create table edges (source string, target string, weight real)");

                //Get the current graph in the defined workspace
                GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
                GraphModel graphModel = graphController.getModel(workspace);
                Graph graph = graphModel.getGraphVisible();

                //Count the number of tasks (nodes + edges) and start the progress
                int tasks = graph.getNodeCount() + graph.getEdgeCount();
                Progress.start(progress, tasks);
View Full Code Here

    @Override
    public void actionPerformed(ActionEvent e) {
        //Get the current graph model
        GraphController gc = Lookup.getDefault().lookup(GraphController.class);
        GraphModel graphModel = gc.getModel();
       
        if (graphModel != null) {
            //Remove self loops
            int removed = 0;
            Graph graph = graphModel.getGraph();
            graph.writeLock();
            for(Edge edge : graph.getEdges().toArray()) {
                if(edge.isSelfLoop()) {
                    graph.removeEdge(edge);
                    removed++;
View Full Code Here

        assertEquals(diameter, 4.0);
    }

    @Test
    public void testOneNodeRadius() {
        GraphModel graphModel = GraphGenerator.generateNullUndirectedGraph(1);

        GraphDistance d = new GraphDistance();
        d.initializeStartValues();
        UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
        HashMap<Node, Integer> indicies = d.createIndiciesMap(undirectedGraph);

        d.calculateDistanceMetrics(graphModel.getGraph(), indicies, false, false);

        double radius = d.getRadius();
        assertEquals(radius, 0.0);
    }
View Full Code Here

        assertEquals(radius, 0.0);
    }

    @Test
    public void testTwoConnectrdNodesRadius() {
        GraphModel graphModel = GraphGenerator.generatePathUndirectedGraph(2);

        GraphDistance d = new GraphDistance();
        d.initializeStartValues();
        UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
        HashMap<Node, Integer> indicies = d.createIndiciesMap(undirectedGraph);

        d.calculateDistanceMetrics(graphModel.getGraph(), indicies, false, false);

        double radius = d.getRadius();
        assertEquals(radius, 1.0);
    }
View Full Code Here

        assertEquals(radius, 1.0);
    }

    @Test
    public void testNullGraphRadius() {
        GraphModel graphModel = GraphGenerator.generateNullUndirectedGraph(5);

        GraphDistance d = new GraphDistance();
        d.initializeStartValues();
        UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
        HashMap<Node, Integer> indicies = d.createIndiciesMap(undirectedGraph);

        d.calculateDistanceMetrics(graphModel.getGraph(), indicies, false, false);

        double radius = d.getRadius();
        assertEquals(radius, 0.0);
    }
View Full Code Here

TOP

Related Classes of org.gephi.graph.api.GraphModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.