See also: API Objects, Edge Methods, Container Methods, Serialization
Vertex methods allow you to add and remove vertices from a DirectedGraph
container instance, attach, query, and remove
application-specific properties from vertices, and determine which other vertices are adjacent to a specific vertex.
Generally, vertex methods accept vertex read and vertex write objects as input parameters. These objects are explained
in the API Objects section.
digraph.isVertex(string);
Request
vertex read request
Response
Boolean true iff the vertex exists in the container. Otherwise false.
Notes
If you pass the ID of a non-existent vertex, or bad input the response will be false.
var response = digraph.addVertex({ u: string, p: data});
Request
vertex write request
Response
JavaScript object with the following properties:
Notes
If specified, property data should be serializable to JSON. If you need to associate non-serializable data with a vertex, use an external dictionary indexed by vertex identifier.
If the vertex already exists in the container and property data was specified, then addVertex
updates the vertex's
property data in the container.
If the vertex already exists and no property data is specified, addVertex
does nothing.
If your intention is to disassociate the vertex from property data, call clearVertexProperty
method.
The setVertexProperty
method is a convenience alias for the addVertex
and their behavior is identical in all respects.
digraph.removeVertex(string);
Request
vertex read request
Response
Returns true if the vertex was removed. Otherwise, false.
Notes If the response is true, then all edges (both in and out-edges) directed towards and away from the removed vertex are automatically removed as well.
If you pass bad input, or the vertex doesn't exist in the container the call returns false.
var response = digraph.getVertexProperty(string);
Request
vertex read request
Response
Returns a reference to data associated with the vertex in the container. If the vertex has no associated property data, the call returns undefined.
Notes
getVertexProperty
will return undefined if passed bad input.
setVertexProperty
is an alias for method addVertex
.
var response = digraph.hasVertexProperty(string);
Request
vertex read request
Response
Returns true if the vertex has associated property data. Otherwise, false.
Notes:
hasVertexProperty
will return false if the request is invalid, or the vertex does not exist in the graph,
or the vertex exists and does not have associated property data.
var response = digraph.clearVertexProperty(string);
Request vertex read request
Return
Returns true to indicate that the vertex property data has been cleared. Otherwise, false.
Notes
clearVertexProperty
will return false if the request is invalid, or if the vertex does not exist in the graph.
var response = digraph.inDegree(string);
Request
vertex read request
Response
Integer indicating the in-degree of the specific vertex.
Notes
inDegree
will return minus one (-1) if the request is invalid.
var response = digraph.inEdges(string);
Request
vertex read request
Response
Array of edge descriptor objects specifying the source and sink vertex ID's of each of the specified vertex's in-edges.
response = [
{ u: string, v: string },
//...
];
Notes
inEdges
will return an empty array if the request is invalid, or if the vertex has no in-edges.
var response = digraph.outDegree(string);
Request
vertex read request
Response
Integer indicating the out-degree of the specific vertex.
Notes
outDegree
will return minus one (-1) if the request is invalid.
var response = digraph.outEdges(string);
Request
vertex read request
Response
Array of edge descriptor objects specifying the source and sink vertex ID's of each of the specified vertex's out-edges.
response = [
{ u: string, v: string },
// ...
]
Notes
outEdges
will return an empty array if the request is invalid, or if the vertex has no in-edges.