Class: Edge

Edge

new Edge(nodes, props)

Constructs a new Edge
Parameters:
Name Type Description
nodes Array Array of two Nodes representing a graph edge. Since an Edge is undirected, the order of the Nodes in the Array does not matter.
props Object Object containing optional properties of the Edge
Properties
Name Type Description
color Number | String Hexadecimal or CSS-style string representation of a color; defaults to 'white'
Source:

Methods

(private) _initProps(properties) → {Edge}

Initialize Edge properties
Parameters:
Name Type Description
properties Object Properties passed in from the constructor
Source:
Returns:
The Edge the method was called on
Type
Edge

addTo(graph) → {Edge}

Add the Edge to a Graph. Upon adding, if the Edge contains Node string ID's, they will be looked up in the Graph and replaced with Node instances.
Parameters:
Name Type Description
graph Graph Graph the Edge will be added to
Source:
Returns:
The Edge the method was called on
Type
Edge

color() → {String}

Gets the color of the Edge
Source:
Returns:
String hexadecimal representation of the Edge's color
Type
String
Example
myEdge.setColor("green");
myEdge.color();  // returns "008000"

nodes() → {Array}

Get the nodes of the Edge
Source:
Returns:
Array of two Nodes that represent the ends of the Edge
Type
Array

setColor(color) → {Edge}

Set the color of the Edge
Parameters:
Name Type Description
color Number | String Hexadecimal or CSS-style string representation of a color
Source:
Returns:
The Edge the method was called on
Type
Edge
Examples
myEdge.setColor(0x00ffbb);
myEdge.setColor("rgb(250,0,0)");
myEdge.setColor("green");

setNodes(nodes) → {Edge}

Set the nodes of the Edge
Parameters:
Name Type Description
nodes Array Array of two Nodes
Source:
Returns:
The Edge the method was called on
Type
Edge