Graph Class
A Graph. Contains a list of Vertex objects, each of which has 0..N Ports, and a list of Edge objects. Every instance of the jsPlumb Toolkit is backed by an instance of this class.
A good discussion on Graphs can be found on Wikipedia: http://en.wikipedia.org/wiki/Graph_(mathematics).
You will not typically need to construct a Graph directly (at least not when using the Toolkit; there is nothing stopping you from using this class directly for other purposes).
Constructor
Graph

[params]
Parameters:

[params]
Object optionalConstructor parameters. Optional. The Graph class has sensible defaults.

[defaultDirected=true]
Boolean optionalWhether edges are directed by default.

[idFunction]
Function optionalFunction to use to extract an appropriate ID from the JSON for a give node. Defaults to returning the 'id' property of the JSON.

[enableSubgraphs=false]
Boolean optionalIf true, Nodes are Graphs themselves, and can have child Nodes. If you enable this then you cannot use slashes (/) in your Node ids, as they will be treated as components of a path to a Node in a nested Graph.

[defaultCost=1]
Number optionalDefault cost for Edges.

[portSeparator="."]
String optionalThe character(s) used to separate ports from nodes in port ids.

Item Index
Methods
 addEdge
 addNode
 addNodes
 clear
 deleteEdge
 deleteGroup
 deleteNode
 findPath
 getBetweenness
 getCentrality
 getCloseness
 getDiameter
 getDistance
 getEdge
 getEdgeCount
 getFarness
 getGroupAt
 getGroups
 getIdFunction
 getIndegreeCentrality
 getNode
 getNodeAt
 getNodeCount
 getNodes
 getOutdegreeCentrality
 getVertexByPortId Looks up a vertex identified by the port id, which is in full port id (vertexId.portId) format, returning null if nothing found. (Note that we show full port id format as vertexId.portId, but the '.' is just the default portSeparator; it is possible to change that to some other character)
 printPath
 setIdFunction
 setIdFunction
 setPortSeparator
 setSource
 setTarget
Methods
addEdge

params
Adds an Edge to the Graph.
Parameters:

params
ObjectParameters for new Edge.

source
String  Node  PortSource for the Edge  a Node, Port or Node/Port id.

target
String  Node  PortTarget for the Edge  a Node, Port or Node/Port id.

[cost=1]
Integer optionalEdge cost. This is used when computing shortest paths through the graph. If an Edge is not
directed
, then the same cost is applied regardless of the direction of traversal. 
[directed=true]
Boolean optionalWhether or not the Edge is directed.

[data]
Object optionalOptional data to associate with the Edge. The default edgeIdFunction

Returns:
The Edge that was added.
addNode

data

[idFunction]

The
Adds a Node to the Graph
Parameters:

data
ObjectBacking data for the Node

[idFunction]
Function optionalOptional function to use to retrieve ID from backing data. Defaults to retrieving
id
from data object. 
The
NodeNode that was added.
addNodes

data

[idFunction]
Adds a list of Nodes to the Graph
Parameters:

data
ObjectList of data objects, one for each Node to be added.

[idFunction]
Function optionalOptional function to use to retrieve ID from backing data. Defaults to retrieving
id
from data object.
clear
()
Clears the Graph of all its Nodes, Ports and Edges.
deleteGroup

g

[removeMembers=false]
Deletes a Group
Parameters:

g
Node  StringEither a Group, or a Group id.

[removeMembers=false]
Boolean optionalIf true, also remove all the Nodes that are members of the Group.
findPath

source

target

[strict=true]

[nodeFilter]

[edgeFilter]
Finds the shortest path from source to target, using the Djikstra algorithm.
Parameters:

source
Node  StringSource Node or Node ID.

target
Node  StringTarget Node or Node ID.

[strict=true]
Boolean optionalSets whether or not paths are searched strictly by the given source/target. If, for instance, you supply a node as the source, but there are only edges connected to ports on that node, by default these edges will be ignored. Switching
strict
to false will mean these edges are considered. 
[nodeFilter]
Function optionalOptional function that is given each Node's backing data and asked to return true or false  true means include the Node, false means exclude it.

[edgeFilter]
Function optionalOptional function that is given each Edge's backing data and asked to return true or false  true means include the Edge, false means exclude it.
Returns:
An array like [ \, \{ vertex,cost,edge \} ... ]
when successful; when unsuccessful the three compiled
tables are returned  distances to nodes, each node's previous node, and the associated edge. so you can call this method with
no target set and get the entire table populated.
getBetweenness

node
Returns the betweenness centrality of the given node.
Parameters:

node
Node  StringNode, or Node ID, to retrieve betweenness centrality for.
Returns:
Node's "betweenness" centrality.
getCentrality

node
Returns the degree centrality of the given node. This is an alias to getDegreeCentrality
, as centrality
most commonly refers to degree centrality. Note that this returns incoming and outgoing connections; use
getIndegreeCentrality or getOutdegreeCentrality if you need to be more specific.
Parameters:

node
Node  StringNode, or Node ID, to retrieve centrality for.
Returns:
Node's centrality.
getCloseness

node
Returns the Closeness centrality of the given node. This is the inverse of the node's farness.
Parameters:

node
Node  StringNode, or Node ID, to retrieve closeness for.
Returns:
Node's "closeness".
getDiameter

[dontUseMax=false]
Returns the diameter
of the Graph.
Parameters:

[dontUseMax=false]
Boolean optionalWhether or not to return Infinity if there is at least one pair of nodes for which there is no available path.
Returns:
Diameter of the Graph.
getDistance

source

target

[strict=true]
Finds the distance between source and target.
Parameters:

source
Node  StringSource Node or Node ID.

target
Node  StringTarget Node or Node ID.

[strict=true]
Boolean optionalSets whether or not paths are searched strictly by the given source/target. If, for instance, you supply a node as the source, but there are only edges connected to ports on that node, by default these edges will be ignored. Switching
strict
to false will mean these edges are considered.
Returns:
Distance from the source to the target.
getEdge

e
Gets an Edge by id, or if the given object is already an Edge, hands that back.
Parameters:

e
String  Edge  ObjectID of the Edge to retrieve, or an actual Edge, or some data from which an ID could be derived.
Returns:
The requested Edge, if found, otherwise null.
getEdgeCount
()
Integer
Returns the total number of Edges in the graph.
Returns:
The total number of Edges.
getFarness

node
Returns the farness centrality of the given node, ie. the sum of its distance from all other nodes, where the distance from one Node to another is given by the associated cost of the Edge joining the two Nodes.
Parameters:

node
Node  StringNode, or Node ID, to retrieve farness for.
Returns:
Node's "farness".
getGroupAt

idx
Returns the Group at the given index.
Parameters:

idx
NumberIndex into group list
Returns:
a Group, or null if not found.
getIdFunction
()
Function
Gets the current function to use to extract an appropriate ID from the JSON for any given object.
Returns:
Function in use for extracting IDs.
getIndegreeCentrality

node
Returns the indegree centrality of the given node (number of connections entering the vertex)
Parameters:

node
Node  StringNode, or Node ID, to retrieve indegree centrality for.
Returns:
Node's indegree centrality.
getNode

id
Gets the Node or Port with the given id, null if not found.
Parameters:

id
StringNode or Port id.
Returns:
Node/Port if found, null otherwise.
getNodeAt

index
Returns the Node at the given index (used for bulk init type purposes)
Parameters:

index
IntegerIndex of the Node to retrieve
Returns:
Node at the given index.
getNodeCount
()
Integer
Gets the count of Nodes in the Graph.
Returns:
The total number of Nodes in the graph.
getOutdegreeCentrality

node
Returns the outdegree centrality of the given node (number of connections exiting the vertex)
Parameters:

node
Node  StringNode, or Node ID, to retrieve outdegree centrality for.
Returns:
Node's indegree centrality.
getVertexByPortId
Looks up a vertex identified by the port id, which is in full port id (vertexId.portId) format, returning null if nothing found.
(Note that we show full port id format as vertexId.portId, but the '.' is just the default portSeparator; it is possible to change that
to some other character)

portId
Parameters:

portId
Object
Returns:
printPath
()
String
Returns the path from source to target as a String.
Returns:
Printed path. Mostly useful for debugging.
setIdFunction

f
Sets the default function to use to extract an appropriate type from the JSON for any given object.
Parameters:

f
FunctionFunction to use to extract IDs.
setIdFunction

idFunction
Sets the default function to use to extract an appropriate ID from the JSON for any given object.
Parameters:

idFunction
FunctionFunction to use to extract IDs.
setPortSeparator

separator
Sets the character(s) used to separate ports from nodes in port ids. By default this is '.', ie a
port is addressed as nodeId.portId
. This may need to be changed depending on the data in your model.
Parameters:

separator
StringSeparator to use.
setSource

o
Sets the source Node/Port for some Edge.