Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function myFirstFunction(){
- alert("hello world");
- }
- function graph(){
- this.nodes=[];
- this.edges=[];
- this.addNode = function(newNode){ //defines addNode as a function
- var newNodeIndex = this.nodes.indexOf(newNode);
- if(newNodeIndex != -1){
- return; //escape if newNode already in nodes
- }
- this.nodes.push(newNode); //adds newNode to the array this.nodes PUSH=APPEND
- }
- this.addEdge = function(newEdge){
- var newEdgeIndex = this.edges.indexOf(newEdge);
- if(newNodeIndex != -1){
- return;
- }
- this.edges.push(newEdge);
- }
- this.areAdjacent = function(node1,node2){
- var edgeForward = [node1,node2]
- var edgeBackward = [node2,node1]
- //for(var edge in )
- }
- }
- array.prototype.indexOf = function(element){
- for(var index in this){
- if(this[index]==element){
- return index;
- }
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement