Ejemplo n.º 1
0
    /// <summary>
    /// Creates a new Node with the given position, generating a unique ID
    /// </summary>
    /// <param name="position"></param>
    /// <returns></returns>
    public Node CreateNode(Vector3 position)
    {
        //Debug.Log("Graph: Create Node at Position " + position);
        // Declare and instantiate a new node with a unique ID...
        Node newNode = new Node(
            this,
            IDUtils.GetUniqueID("Node", string.Empty, this.nodes, 10000),
            position);

        // ... add the node to the nodes-list...
        AddNode(newNode);

        // ... and return the new node.
        return(newNode);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Creates a new Edge between the given from- and to-node and adds it to the edges-list
    /// </summary>
    /// <param name="from">The start-node of the new edge</param>
    /// <param name="to">The end-node of the new edge</param>
    /// <returns>The newly created edge.</returns>
    public Edge CreateEdge(Node from, Node to)
    {
        //Debug.Log("Graph: Create Edge for From-Node " + from.Id + " and To-Node " + to.Id);
        // Declare and instantiate a new Edge between the given nodes with a unique ID...
        Edge newEdge = new Edge(
            this,
            IDUtils.GetUniqueID("Edge", string.Empty, this.edges, 10000),
            from, to);

        // ... add the new edge to the edges-list...
        AddEdge(newEdge);

        // ...and return the new edge.
        return(newEdge);
    }
Ejemplo n.º 3
0
 public Node(Graph graph, Vector3 position)
     : this(graph)
 {
     this.id        = IDUtils.GetUniqueID("Node", string.Empty, this.graph.Nodes, 10000);
     this._position = position;
 }