graph.js整合node和edge资源,对外提供访问接口

来源:互联网 发布:数据库原理视频专辑 编辑:程序博客网 时间:2024/06/03 04:27


/*
 Class: Graph
 A Graph Class that provides useful manipulation functions. You can find more manipulation methods in the <Graph.Util> object.
 An instance of this class can be accessed by using the *graph* parameter of any tree or graph visualization.
 
 Example:
 (start code js)
   //create new visualization
   var viz = new $jit.Viz(options);
   //load JSON data
   viz.loadJSON(json);
   //access model
   viz.graph; //<Graph> instance
 (end code)
 
 Implements:
 
 The following <Graph.Util> methods are implemented in <Graph>
 
  - <Graph.Util.getNode>
  - <Graph.Util.eachNode>
  - <Graph.Util.computeLevels>
  - <Graph.Util.eachBFS>
  - <Graph.Util.clean>
  - <Graph.Util.getClosestNodeToPos>
  - <Graph.Util.getClosestNodeToOrigin>
 
*/  


$jit.Graph = new Class({            initialize: function(opt, Node, Edge, Label) {                     this.Node = Node;   //存储node的配置项                    this.Edge = Edge;    //存储edge的配置项                  this.Label = Label;                  this.opt = $.merge(innerOptions, opt || {});                 this.nodes = {}; //存储所有的nodes                 this.edges = {};     //存储所有的edges},           getNode: function(id) {},          getByName: function(name) {},          getAdjacence: function (id, id2) {},          addNode: function(obj) {},         addAdjacence: function (obj, obj2, data) {},         removeNode: function(id) {},         removeAdjacence: function(id1, id2) {},         hasNode: function(id) {},          empty: function() {}});



后续更新。。。。









         

阅读全文
0 0
原创粉丝点击