This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| generateRandomNetwork(graph, 10); | |
| writeToJSON(graph.graph, "graph"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a -> { b c } | |
| b -> { a d } | |
| c -> { a } | |
| d -> { b c } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| graph.get("Fabian").addConnection(graph.get("Rey")); | |
| graph.get("Fabian").addConnection(graph.get("Ellie")); | |
| graph.get("Fabian").addConnection(graph.get("Cassi")); | |
| graph.get("Ellie").addConnection(graph.get("Cassi")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const graph = new Graph(); | |
| graph.addNode(fabian); | |
| graph.addNode(rey); | |
| graph.addNode(ellie); | |
| graph.addNode(cassi); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fabian = new Node({ name: "Fabian" }); | |
| const rey = new Node({ name: "Rey" }); | |
| const ellie = new Node({ name: "Ellie" }); | |
| const cassi = new Node({ name: "Cassi" }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Node.prototype.addConnection = function(user) { | |
| if (!this.friends[user.name]) { | |
| this.friends[user.name] = { name: user.name }; | |
| user.addConnection(this); | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Node(user) { | |
| this.name = user.name; | |
| this.friends = {}; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Graph.prototype.addUser = function(user) { | |
| this.graph[user.name] = user; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Graph.prototype.getNode = function(name) { | |
| return this.graph[name]; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Graph() { | |
| this.graph = {}; | |
| } |
NewerOlder