-
Notifications
You must be signed in to change notification settings - Fork 25
added path support #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| "use strict"; | ||
| /** | ||
| * An edge connecting two nodes. | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| "use strict"; | ||
| const redis = require("redis"), | ||
| util = require("util"), | ||
| ResultSet = require("./resultSet"); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| "use strict"; | ||
| /** | ||
| * Different Statistics labels | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| "use strict"; | ||
| /** | ||
| * A node within the garph. | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| "use strict"; | ||
| class Path { | ||
| constructor(nodes, edges){ | ||
| this.nodes = nodes; | ||
| this.edges = edges; | ||
| } | ||
|
|
||
| get Nodes(){ | ||
| return this.nodes; | ||
| } | ||
|
|
||
| get Edges(){ | ||
| return this.edges; | ||
| } | ||
|
|
||
| getNode(index){ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should you use gettter/setter?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please elaborate
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is a property getter, so done, for every zero parametes function |
||
| return this.nodes[index]; | ||
| } | ||
|
|
||
| getEdge(index){ | ||
| return this.edges[index]; | ||
| } | ||
|
|
||
| get firstNode(){ | ||
| return this.nodes[0]; | ||
| } | ||
|
|
||
| get lastNode(){ | ||
| return this.nodes[this.nodes.length -1]; | ||
| } | ||
|
|
||
| get nodeCount(){ | ||
| return this.nodes.length; | ||
| } | ||
|
|
||
| get edgeCount(){ | ||
| return this.edges.length; | ||
| } | ||
|
|
||
| toString() { | ||
| return JSON.stringify(this); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| module.exports = Path; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| "use strict"; | ||
| /** | ||
| * Hold a query record | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| "use strict"; | ||
| const Label = require("./label"); | ||
|
|
||
| class Statistics { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| "use strict"; | ||
| const Node = require("../src/node"), | ||
| Edge = require("../src/edge"), | ||
| Path = require("../src/path"); | ||
|
|
||
| class PathBuilder { | ||
| constructor(nodeCount){ | ||
| this.nodes = new Array(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
| this.edges = new Array(); | ||
| this.currentAppendClass = Node; | ||
| } | ||
|
|
||
| append(obj){ | ||
| if(! obj instanceof this.currentAppendClass) throw "Error in path build insertion order and types." | ||
| if(obj instanceof Node) return this._appendNode(obj); | ||
| else return this._appendEdge(obj); | ||
| } | ||
|
|
||
| build(){ | ||
| return new Path(this.nodes, this.edges); | ||
| } | ||
|
|
||
| _appendNode(node){ | ||
| this.nodes.push(node); | ||
| this.currentAppendClass = Edge; | ||
| return this; | ||
| } | ||
|
|
||
| _appendEdge(edge){ | ||
| this.edges.push(edge); | ||
| this.currentAppendClass = Node; | ||
| return this; | ||
| } | ||
| } | ||
|
|
||
| module.exports = PathBuilder; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DvirDukhan capital letter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed