Advertisement
Guest User

Untitled

a guest
Aug 20th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. function myFirstFunction(){
  2. alert("hello world");
  3.  
  4. }
  5.  
  6. function graph(){
  7. this.nodes=[];
  8. this.edges=[];
  9.  
  10. this.addNode = function(newNode){ //defines addNode as a function
  11. var newNodeIndex = this.nodes.indexOf(newNode);
  12. if(newNodeIndex != -1){
  13. return; //escape if newNode already in nodes
  14. }
  15. this.nodes.push(newNode); //adds newNode to the array this.nodes PUSH=APPEND
  16. }
  17.  
  18.  
  19. this.addEdge = function(newEdge){
  20. var newEdgeIndex = this.edges.indexOf(newEdge);
  21. if(newNodeIndex != -1){
  22. return;
  23. }
  24. this.edges.push(newEdge);
  25. }
  26.  
  27. this.areAdjacent = function(node1,node2){
  28. var edgeForward = [node1,node2]
  29. var edgeBackward = [node2,node1]
  30. //for(var edge in )
  31.  
  32. }
  33. }
  34.  
  35.  
  36. array.prototype.indexOf = function(element){
  37. for(var index in this){
  38. if(this[index]==element){
  39. return index;
  40. }
  41. }
  42. return -1;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement