ARCcore.graph DirectedGraph Container Methods
Login
-Home
/
-Documentation
/
-ARCcore
/
-graph
/
-DirectedGraph
/
Container Methods
-DirectedGraph
+Algorithms
Examples
Vertex Methods
Edge Methods
Container Methods
API Objects
Serialization
DirectedGraph Container Methods Documentation
DirectedGraph container methods operate on the contents of the whole container.

See also: Serialization Reference

Container methods allow you to get and set the name and description of a DirectedGraph container instance, obtain counts and sets of vertices and edges in the container, serialize the contents of the container, and import another serialized DirectedGraph instance into an existing container instance.

DirectedGraph.setGraphName

var response = digraph.setGraphName("WA State Driving Routes");
if (response.error)
    console.error(response.error);

Request

string

Response

Response object with error and result properties.

If error is not null, it is a string indicating what the problem was.

If error is not null, then result is Boolean true.

Notes

Typically the digraph name is set at container construction. See Serialization Reference.

DirectedGraph.getGraphName

var name = digraph.getGraphName();
console.log(name);

Request

No in-params

Response

Returns string that may be zero-length if no graph name was set.

DirectedGraph.setGraphDescription

var response = digraph.setGraphDescription("Scenic WA driving routes digraph model");
if (response.error)
    console.error(response.error);

Request

string

Response

Response object with error and result properties.

If error is not null, it is a string indicating what the problem was.

If error is not null, then result is Boolean true.

Notes

Typically the digraph name is set at container construction. See Serialization Reference.

DirectedGraph.getGraphDescription

var description = digraph.getGraphDescription();
console.log(description);

Request

No in-params

Response

Returns string that may be zero-length if no graph description was set.

DirectedGraph.verticesCount

var vertexCount = digraph.verticesCount();
console.log(vertexCount + " vertices");

Request

No in-params

Response

Integer indicating the number of vertices in this graph.

DirectedGraph.getVertices

var vertexSet = digraph.getVertices();
console.log(JSON.stringify(vertices));

Request

No in-params

Response

Returns an array of string vertex identifiers.

Notes

Do not count on the order of vertices in the set - it's not significant and might change in a future release.

DirectedGraph.edgesCount

var edgeCount = digraph.edgesCount();
console.log(edgeCount + " edges");

Request

No in-params

Response

Integer indicating the number of edges in this graph.

DirectedGraph.getEdges

var edgeSet = digraph.getEdges();
console.log(JSON.stringify(edgeSet));

Request

No in-params

Response Returns an array of edge descriptor objects with u and v properties.

Notes

Do not count on the order of the edges in the set - it's not significant and might change in a future release.

DirectedGraph.rootVerticesCount

var rootVertexCount = digraph.rootVerticesCount();
console.log(rootVerticesCount + " root vertices");

Request

No in-params

Response

Integer count of the number of vertices with in-degree equal to zero (0).

DirectedGraph.getRootVertices

var rootVertexSet = digraph.getRootVertices();
console.log(JSON.stringify(rootVertexSet));

Request

No in-params

Response

Returns an array of identifier strings indicating the set of root vertices in the graph (i.e. the set of vertices with in-degree zero).

Notes

Do not count on the order of the vertices in the set - it's not significant and might change in a future release.

DirectedGraph.leafVerticesCount

var leafVertexCount = digraph.leafVerticesCount();
console.log(leafVertexCount + " leaf vertices");

Request

No in-params Response

Integer count of the number of vertices with out-degree equal to zero (0).

DirectedGraph.getLeafVertices

var leafVertexSet = digraph.getLeafVertices();
console.log(JSON.stringify(leafVertexSet));

Request

No in-params

Response

Returns an array of identifier strings indicating the set of leaf vertices in the graph (i.e. the set of vertices with out-degree zero).

Notes

Do not count on the order of the vertices in the set - it's not significant and might change in a future release.

DirectedGraph.toObject

Method toObject is a deprecated alias for toJSON that will be removed from a future release.

DirectedGraph.toJSON

See also: Serialization Reference

var serializedDigraph = digraph.toJSON()

Request

No in-params

Response

Returns a serialized data object that contains the serialized contents of the DirectedGraph container.

Notes

The object returned may be passed to the DirectedGraph constructor, or to method fromObject.

The method does not return a JSON string because if you're holding a reference to a DirectedGraph in another structure, and, you call JSON.stringify on that structure the expectation is that the returned JSON string will include the serialized DirectedGraph.

If you want to obtain a JSON string directly from a DirectedGraph instance, call method DirectedGraph.stringify explained next.

DirectedGraph.stringify

See also: Serialization Reference

var json = digraph.stringify(replacer,space);

Request

  • replacer: optional function.
  • space: optional integer number of indent spaces

Response

Returns a a serialized DirectedGraph as a JSON-encoded string.

Remarks:

See JSON.stringify (MDN) for further discussion on replacer and space in-params.

DirectedGraph.fromObject

See also: Serialization Reference

var response = digraph.fromObject(object);

Request

object: a serialized DirectedGraph object.

Response

JavaScript object with the following properties:

  • error: null or a string explaining what went wrong
  • result: true to indicate success or null if error

Notes

fromObject parses the request object and uses addVertex and addEdge methods to add the additional vertices and edges to an existing container. The semantics are thus the same as if you called these methods directly yourself. This facility is useful for initializing or extending the the contents of a DirectedGraph container from multiple sources. Or, when building a DirectedGraph model algorithmically.

DirectedGraph.fromJSON

Identical to fromObject except that the request is a JSON string instead of a serializable data object.

Encapsule Project, Seattle WA
Copyright © 2018 Chris Russell
Sat Dec 15 2018 05:16:40 GMT-0500 (EST)

Encapsule/holism v0.0.26
Documents Under Contruction