# vis.js - A dynamic, browser based visualization library.

# Network - selection

Handles the selection of nodes and edges.

### Options

The options for the selection have to be contained in an object titled 'selection'.

Click on the options shown to show how these options are supposed to be used.

    var options = {
      selection:{
        selectable: true,
        selectConnectedEdges: false
      }
    }

    network.setOptions(options);

All of the individual options are explained here:

name | type | default | description
selectable | Boolean | `true` | When true, the nodes and edges can be selected by the user.
selectConnectedEdges | Boolean | `true` | When true, on selecting a node, its connecting edges are highlighted.

### Methods

This is a list of all the methods in the public API. Options can be set directly to the module or you can use the setOptions method of the network itself and use the module name as an object name.

name | returns | description

getSelection()

    {
      nodes: [Array of selected nodeIds],
      edges: [Array of selected edgeIds]
    }

Returns an object with selected nodes and edges ids.

getSelectedNodes() | `[nodeId1, nodeId2, ..]` | Returns an array of selected node ids.
getSelectedEdges() | `[edgeId1, edgeId2, ..]` | Returns an array of selected edge ids.
getNodeAt( `{x: xPosition DOM, y: yPosition DOM}` ) | nodeId | Returns a nodeId or undefined. The DOM positions are expected to be in pixels from the top left corner of the canvas.
getEdgeAt( `{x: xPosition DOM, y: yPosition DOM}` ) | edgeId | Returns a edgeId or undefined. The DOM positions are expected to be in pixels from the top left corner of the canvas..
selectNodes( `Array with nodeIds`, `[Boolean highlightEdges]` ) | none | Selects the nodes corresponding to the id's in the input array. If highlightEdges is true or undefined, the neighbouring edges will also be selected. This method unselects all other objects before selecting its own objects. Does not fire events.
selectEdges( `Array with edgeIds` ) | none | Selects the edges corresponding to the id's in the input array. This method unselects all other objects before selecting its own objects. Does not fire events.
unselectAll() | none | Unselect all objects. Does not fire events.

### Events

The selection handler does not fire events. All related events are fired by the interaction module because they are triggered by user interaction.