ARCcore.graph DirectedGraph Class
Login
-Home
/
-Documentation
/
-ARCcore
/
-graph
/
-DirectedGraph
-DirectedGraph
+Algorithms
Examples
Vertex Methods
Edge Methods
Container Methods
API Objects
Serialization
DirectedGraph Container Class Documentation
DirectedGraph is an in-memory container for directed mathematical graph datasets

Introduction

ARCcore.graph's DirectedGraph container class provides a normalized API for managing in-memory directed graph data structures regardless of the application-specific semantics you ascribe to the vertices and directed edge relationships you store in the container. And, regardless of any optional property data attached to the vertices and edges.

Many data structures are simply modeled using directed graphs making DirectedGraph an attractive solution for managing run-time data in many common situations.

Consider storing your application-specific data structures as directed graphs and passing around DirectedGraph container references instead of JavaScript object references to avoid serialization problems.

Use of DirectedGraph in your derived library and application code allows you to:

  • Elevate the level of abstraction of your design.
  • Write less code that's more concise and simpler to read.
  • Spend less time in the debugger thanks to helpful error messages.
  • Make your codebase uniform, simple to read, refactor, and re-use.
  • Have more productive discussions with your co-workers.
  • Accommodate changing requirements by design, not reaction.
  • Leverage the included re-usable algorithms.

Construction

See also: Serialization

DirectedGraph, is constructed by calling the arccore.graph.directed.create factory function export.

const graph = require('arccore').graph;
var response = graph.directed.create(/*optional init data*/);
if (!response.error) {
    // container is ready for use
    var digraph = response.result;
    console.log("digraph JSON = '" + digraph.stringify() + "'");
} else {
    // container constructor failed
    console.error(response.error);
}

If the DirectedGraph container is successfully constructed, graph.directed.create returns a response object that looks like this:

{ error: null, result: DirectedGraph }

However, if you call graph.directed.create passing an input parameter to the digraph factory that is invalid the response object looks like this:

{ error: "Some error string explaining what went wrong.", result: null }

It is essential that you check and ensure that response.error === null before using response.result. In the example above, we're actually being verbose; this won't ever fail (tests ensure that). But, that's not the general case where you're likely to be constructing a new DirectedGraph instance from serialized data.

DirectedGraph Methods

Here's a dump of DirectedGraph class methods. Scroll down to the bottom of this page for links to in-depth discussion and references for each method.

$ node
> const arccore = require('arccore');
undefined
> var digraph = arccore.graph.directed.create().result;
undefined
> digraph
DirectedGraph {
  getGraphName: [Function],
  setGraphName: [Function],
  getGraphDescription: [Function],
  setGraphDescription: [Function],
  isVertex: [Function],
  addVertex: [Function],
  removeVertex: [Function],
  getVertexProperty: [Function],
  setVertexProperty: [Function],
  hasVertexProperty: [Function],
  clearVertexProperty: [Function],
  inDegree: [Function],
  inEdges: [Function],
  outDegree: [Function],
  outEdges: [Function],
  isEdge: [Function],
  addEdge: [Function],
  removeEdge: [Function],
  getEdgeProperty: [Function],
  setEdgeProperty: [Function],
  hasEdgeProperty: [Function],
  clearEdgeProperty: [Function],
  verticesCount: [Function],
  getVertices: [Function],
  edgesCount: [Function],
  getEdges: [Function],
  rootVerticesCount: [Function],
  getRootVertices: [Function],
  leafVerticesCount: [Function],
  getLeafVertices: [Function],
  toJSON: [Function],
  toObject: [Function],
  stringify: [Function],
  fromObject: [Function],
  fromJSON: [Function],
  _private:
   { name: '',
     description: '',
     vertexMap: {},
     rootMap: {},
     leafMap: {},
     edgeCount: 0,
     constructionError: null } }
>

DirectedGraph API Reference

Vertex Methods - ARCcore.graph DirectedGraph Vertex Methods
ARCcore.graph DirectedGraph vertex methods documentation.
Edge Methods - ARCcore.graph DirectedGraph Edge Methods
ARCcore.graph DirectedGraph edge methods documentation.
Container Methods - ARCcore.graph DirectedGraph Container Methods
ARCcore.graph DirectedGraph container methods documentation.
API Objects - ARCcore.graph DirectedGraph API Parameter Objects
ARCcore.graph DirectedGraph API standard parameter objects.
Serialization - ARCcore.graph DirectedGraph Serialization Reference
ARCcore.graph DirectedGraph serialization & deserialization reference.
Encapsule Project, Seattle WA
Copyright © 2023 Chris Russell
Fri Mar 31 2023 15:32:22 GMT-0400 (Eastern Daylight Time)

undefined/@encapsule/holism v0.0.10
undefined/polytely-app-runtime v