示例#1
0
        internal void AddConnection(Node targetNode, double distance, bool twoWay)
        {
            if (targetNode == null) throw new ArgumentNullException("targetNode");
            if (targetNode == this)
                throw new ArgumentException("Node may not connect to itself.");
            if (distance <= 0) throw new ArgumentException("Distance must be positive.");

            _connections.Add(new Edge(targetNode, distance));
            if (twoWay) targetNode.AddConnection(this, distance, false);
        }
示例#2
0
文件: Edge.cs 项目: quela/myprojects
 internal Edge(Node target, double distance)
 {
     this.Target = target;
     this.Distance = distance;
 }
示例#3
0
文件: Graph.cs 项目: quela/myprojects
 public void AddNode(string name)
 {
     var node = new Node(name);
     Nodes.Add(name, node);
 }