Skip to content

Commit 13401a0

Browse files
committed
Breaking fix for bug #51 DirectedGraph serialization API.
1 parent 3430b4a commit 13401a0

30 files changed

+145
-120
lines changed

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "jsgraph",
3-
"version": "0.6.1",
3+
"version": "0.7.0",
44
"description": "Generic directed graph container, and visitor algorithms based on a port of the Boost C++ Graph Library API.",
5-
"main": "index.js",
5+
"main": "src/arc_core_graph.js",
66
"scripts": {
77
"test": "mocha -R spec ./test/test-jsgraph.js"
88
},
@@ -25,8 +25,6 @@
2525
"BFS",
2626
"DFS",
2727
"data modeling",
28-
"semantics",
29-
"semantic modeling",
3028
"data",
3129
"JSON",
3230
"data semantics",

src/arc_core_digraph.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*
2-
Encapsule/jsgraph/src/digraph.js
3-
4-
Copyright (C) 2014-2015 Christopher D. Russell
2+
Copyright (C) 2014-2016 Christopher D. Russell
53
64
This library is published under the MIT License and is part of the
75
Encapsule Project System in Cloud (SiC) open service architecture.
@@ -14,10 +12,10 @@
1412
// http://www.boost.org/doc/libs/1_55_0/libs/graph/doc/index.html
1513
// http://en.wikipedia.org/wiki/Directed_graph
1614

17-
var helperFunctions = require('./helper-functions');
18-
var digraphParams = require('./digraph-in-parameters');
19-
var digraphImport = require('./digraph-json-import');
20-
var digraphExport = require('./digraph-json-export');
15+
var helperFunctions = require('./arc_core_graph_util');
16+
var digraphParams = require('./arc_core_digraph_in_params');
17+
var digraphImport = require('./arc_core_digraph_import');
18+
var digraphExport = require('./arc_core_digraph_export');
2119

2220
(function() {
2321
var __bind = function(method, scope){ return function(){ return method.apply(scope, arguments); }; };
@@ -43,7 +41,7 @@ var digraphExport = require('./digraph-json-export');
4341
this.inEdges = __bind(this.inEdges, this);
4442
this.outDegree = __bind(this.outDegree, this);
4543
this.outEdges = __bind(this.outEdges, this);
46-
44+
4745
// Edge-scope methods
4846
this.isEdge = __bind(this.isEdge, this);
4947
this.addEdge = __bind(this.addEdge, this);
@@ -52,7 +50,7 @@ var digraphExport = require('./digraph-json-export');
5250
this.setEdgeProperty = __bind(this.setEdgeProperty, this);
5351
this.hasEdgeProperty = __bind(this.hasEdgeProperty, this);
5452
this.clearEdgeProperty = __bind(this.clearEdgeProperty, this);
55-
53+
5654
// Digraph-scope methods
5755
this.verticesCount = __bind(this.verticesCount, this);
5856
this.getVertices = __bind(this.getVertices, this);
@@ -62,8 +60,9 @@ var digraphExport = require('./digraph-json-export');
6260
this.getRootVertices = __bind(this.getRootVertices, this);
6361
this.leafVerticesCount = __bind(this.leafVerticesCount, this);
6462
this.getLeafVertices = __bind(this.getLeafVertices, this);
65-
this.toObject = __bind(this.toObject, this);
6663
this.toJSON = __bind(this.toJSON, this);
64+
this.toObject = __bind(this.toObject, this);
65+
this.stringify = __bind(this.stringify, this);
6766
this.fromObject = __bind(this.fromObject, this);
6867
this.fromJSON = __bind(this.fromJSON, this);
6968

@@ -96,7 +95,7 @@ var digraphExport = require('./digraph-json-export');
9695
if (helperFunctions.JSType(string_) === '[object String]') {
9796
this._private.name = string_;
9897
response.result = true;
99-
} else {
98+
} else {
10099
response.error = "Invalid graph name specified. Expected '[object String]'.";
101100
}
102101
return response;
@@ -111,7 +110,7 @@ var digraphExport = require('./digraph-json-export');
111110
if (helperFunctions.JSType(string_) === '[object String]') {
112111
this._private.description = string_;
113112
response.result = true;
114-
} else {
113+
} else {
115114
response.error = "Invalid graph name specified. Expected '[object String]'.";
116115
}
117116
return response;
@@ -127,7 +126,7 @@ var digraphExport = require('./digraph-json-export');
127126
var vertex = this._private.vertexMap[vertexId_];
128127
return (vertex !== null) && vertex && true || false;
129128
};
130-
129+
131130
/*
132131
request = {
133132
u: vertex ID string
@@ -512,18 +511,22 @@ var digraphExport = require('./digraph-json-export');
512511
return leafVertices;
513512
};
514513

515-
DirectedGraph.prototype.toObject = function () {
514+
// toJSON and toObject are identical delegations to digraphExport.exportObject.
515+
DirectedGraph.prototype.toJSON = function () {
516+
return digraphExport.exportObject(this);
517+
};
518+
DirectedGraph.prototype.toObject = function() {
516519
return digraphExport.exportObject(this);
517520
};
518521

519-
DirectedGraph.prototype.toJSON = function(replacer_, space_) {
522+
DirectedGraph.prototype.stringify = function(replacer_, space_) {
520523
return digraphExport.exportJSON(this, replacer_, space_);
521524
};
522525

523526
DirectedGraph.prototype.fromObject = function (object_) {
524527
return digraphImport(this, object_);
525528
};
526-
529+
527530
DirectedGraph.prototype.fromJSON = function(json_) {
528531
return digraphImport(this, json_);
529532
};

src/arc_core_digraph_algorithm_bft.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*
2-
Encapsule/jsgraph/src/digraph-algorithm-bft.js
3-
4-
Copyright (C) 2014-2015 Christopher D. Russell
2+
Copyright (C) 2014-2016 Christopher D. Russell
53
64
This library is published under the MIT License and is part of the
75
Encapsule Project System in Cloud (SiC) open service architecture.
@@ -55,9 +53,9 @@
5553
*/
5654

5755
var algorithmName = "BFT"; // constant string used in error messages
58-
var colors = require('./digraph-algorithm-common-colors');
59-
var visitorCallback = require('./digraph-algorithm-common-visit');
60-
var normalizeRequest = require('./digraph-algorithm-common-request');
56+
var colors = require('./arc_core_digraph_algorithm_colors');
57+
var visitorCallback = require('./arc_core_digraph_algorithm_visit');
58+
var normalizeRequest = require('./arc_core_digraph_algorithm_request');
6159

6260

6361
module.exports = function (request_) {

src/arc_core_digraph_algorithm_colors.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*
2-
Encapsule/jsgraph/src/digraph-algorithm-common-colors.js
3-
4-
Copyright (C) 2014-2015 Christopher D. Russell
2+
Copyright (C) 2014-2016 Christopher D. Russell
53
64
This library is published under the MIT License and is part of the
75
Encapsule Project System in Cloud (SiC) open service architecture.

src/arc_core_digraph_algorithm_context.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*
2-
Encapsule/jsgraph/src/digraph-algorithm-common-context.js
3-
4-
Copyright (C) 2014-2015 Christopher D. Russell
2+
Copyright (C) 2014-2016 Christopher D. Russell
53
64
This library is published under the MIT License and is part of the
75
Encapsule Project System in Cloud (SiC) open service architecture.
@@ -10,8 +8,8 @@
108
with in-memory data on Node.js and HTML.
119
*/
1210

13-
var helperFunctions = require('./helper-functions');
14-
var colors = require('./digraph-algorithm-common-colors');
11+
var helperFunctions = require('./arc_core_graph_util');
12+
var colors = require('./arc_core_digraph_algorithm_colors');
1513

1614
module.exports = function (request_) {
1715
var response = { error: null, result: null };

src/arc_core_digraph_algorithm_dft.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*
2-
Encapsule/jsgraph/src/digraph-algorithm-dft.js
3-
4-
Copyright (C) 2014-2015 Christopher D. Russell
2+
Copyright (C) 2014-2016 Christopher D. Russell
53
64
This library is published under the MIT License and is part of the
75
Encapsule Project System in Cloud (SiC) open service architecture.
@@ -11,9 +9,9 @@
119
*/
1210

1311
var algorithmName = "DFT"; // used in error messages
14-
var colors = require('./digraph-algorithm-common-colors');
15-
var visitorCallback = require('./digraph-algorithm-common-visit');
16-
var normalizeRequest = require('./digraph-algorithm-common-request');
12+
var colors = require('./arc_core_digraph_algorithm_colors');
13+
var visitorCallback = require('./arc_core_digraph_algorithm_visit');
14+
var normalizeRequest = require('./arc_core_digraph_algorithm_request');
1715

1816

1917
module.exports = function (request_) {

src/arc_core_digraph_algorithm_request.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*
2-
Encapsule/jsgraph/arc/digraph-algorithm-common-request.js
3-
4-
Copyright (C) 2014-2015 Christopher D. Russell
2+
Copyright (C) 2014-2016 Christopher D. Russell
53
64
This library is published under the MIT License and is part of the
75
Encapsule Project System in Cloud (SiC) open service architecture.
@@ -10,8 +8,8 @@
108
with in-memory data on Node.js and HTML.
119
*/
1210

13-
var helperFunctions = require('./helper-functions');
14-
var TRAVERSE_CONTEXT = require('./digraph-algorithm-common-context');
11+
var helperFunctions = require('./arc_core_graph_util');
12+
var TRAVERSE_CONTEXT = require('./arc_core_digraph_algorithm_context');
1513

1614
/*
1715
request = {

src/arc_core_digraph_algorithm_transpose.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*
2-
Encapsule/jsgraph/src/digraph-algorithm-transpose.js
3-
4-
Copyright (C) 2014-2015 Christopher D. Russell
2+
Copyright (C) 2014-2016 Christopher D. Russell
53
64
This library is published under the MIT License and is part of the
75
Encapsule Project System in Cloud (SiC) open service architecture.
@@ -15,8 +13,8 @@
1513
// More info on directed graph transposition:
1614
// http://www.boost.org/doc/libs/1_55_0/libs/graph/doc/transpose_graph.html
1715

18-
var helperFunctions = require('../src/helper-functions');
19-
var DirectedGraph = require('../src/digraph').DirectedGraph;
16+
var helperFunctions = require('./arc_core_graph_util');
17+
var DirectedGraph = require('./arc_core_digraph').DirectedGraph;
2018

2119
/*
2220
request = DirectedGraph reference

src/arc_core_digraph_algoithm_visit.js renamed to src/arc_core_digraph_algorithm_visit.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*
2-
Encapsule/jsgraph/src/digraph-algorithm-common-visit.js
3-
4-
Copyright (C) 2014-2015 Christopher D. Russell
2+
Copyright (C) 2014-2016 Christopher D. Russell
53
64
This library is published under the MIT License and is part of the
75
Encapsule Project System in Cloud (SiC) open service architecture.
@@ -12,7 +10,7 @@
1210

1311
// Wraps call to DirectedGraph algorithm visitor function callbacks.
1412

15-
var helperFunctions = require('./helper-functions');
13+
var helperFunctions = require('./arc_core_graph_util');
1614

1715
/*
1816
request = {

src/arc_core_digraph_export.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*
2-
Encapsule/jsgraph/src/digraph-json-export.js
3-
4-
Copyright (C) 2014-2015 Christopher D. Russell
2+
Copyright (C) 2014-2016 Christopher D. Russell
53
64
This library is published under the MIT License and is part of the
75
Encapsule Project System in Cloud (SiC) open service architecture.
@@ -16,7 +14,7 @@
1614
// constructor parameter to restore container state across
1715
// execution contexts.
1816

19-
var helperFunctions = require('./helper-functions');
17+
var helperFunctions = require('./arc_core_graph_util');
2018
var DigraphDataExporter = module.exports = {};
2119

2220
DigraphDataExporter.exportObject = function (digraph_) {

0 commit comments

Comments
 (0)