Nodes and Edges#
Nodes#
Nodes are architypes forming part of a graph, holding properties. They can be compared to custom classes in object-oriented programming (OOP).
Custom Node Types#
- You can define custom node types to create specific instances within the graph.
- Each node can have
attributes
(like fields in a class) andabilities
(similar to methods in OOP).
Abilities in Nodes#
-
Callable Abilities: They are similar to standard methods in OOP. Inside any ability, the node can refer to itself using the
self
keyword, much like in OOP. -
Visit-dependent Abilities: These abilities are only triggered when a specific type of "walker" (discussed later) interacts with the node. This ensures that certain actions are performed only in response to a walker's visit. In these abilities, a special keyword
here
is used to reference the visiting walker. This allows you to access the walker's attributes and abilities directly during its interaction with the node. -
This is an example of defining a node.
Connecting Nodes#
Nodes in JacLang can establish connections in various ways, offering flexibility for building complex graphs:
- One-to-One: A single node connects to another single node.
- One-to-Many: A single node connects to multiple nodes.
- Many-to-One: Multiple nodes connect to a single node.
- Many-to-Many: A group of nodes connects to another group of nodes.
This versatility allows for creating intricate and highly interconnected graph structures, tailored to the specific needs of your application.
Edges#
Nodes can be linked using either default edges (generic connections) or custom edges, which have specific properties as shown in the following examples.
To delete an edge between two nodes the `del
keyword can be used as shown below.