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
|
Methods
(private) _initProps(properties) → {Edge}
Initialize Edge properties
Parameters:
Name | Type | Description |
---|---|---|
properties |
Object | Properties passed in from the constructor |
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 |
Returns:
The Edge the method was called on
- Type
- Edge
color() → {String}
Gets the color of the Edge
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
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 |
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 |
Returns:
The Edge the method was called on
- Type
- Edge