Graph Selection

Add custom Cytoscape selection menu items. Graph provides select all, none, and invert by default.

Tutorial

This tutorial will create a selection menu item to select a random node or edge.

Web Plugin

Register the plugin script in a web plugin.

app.registerJavaScript("/org/visallo/examples/graph_selection/plugin.js", true);

Register Extension

Register the selection extension to find a random element and select it.

require(['public/v1/api'], function(visallo) {

    var doRandomSelection = function(cy) {
        var elements = cy.elements('.v,.e').unselect(),
            randomIndex = Math.floor(Math.random() * elements.length);
        elements[randomIndex].select();
    }
    doRandomSelection.identifier = 'org-visallo-examples-graph-selection';
    doRandomSelection.visibility = 'always';

    visallo.registry.registerExtension('org.visallo.graph.selection', doRandomSelection);
});

The elements function in cytoscape will return all nodes and edges. This includes decorations on nodes, and temporary edges used for find path, etc. Filter by .v,.e to include only real vertices and edges.

results matching ""

    No results matching ""