Node

From OpenCog
Jump to: navigation, search

Nodes are Atoms with names. The name and the type of a Node together determine a unique key. It means there exist only one Node with a given (name,type) pair. If a second Node with the same key is inserted, it is merged with the previously inserted Node. The name and type of the node cannot be changed after the node has been inserted into the AtomSpace: OpenCog atoms are immutable objects.

Scheme interface

Nodes can be created, manipulated and destroyed at the scheme shell command prompt. See scheme for details.

C++ programming interface

   class Node : public Atom
   {
       private:
         std::string name;
       public:
         Node(Type, std::string &);
         const std::string& getName() const;
         std::string toString() const;
   };

getName() returns the name of the node; toString() returns a string representation (with type, name, truth value and attention value) of the Node.

Considering the following example:

L1 A B
L2 A C
L3 D B
L4 L1 A