liveBook · Manning

Node

As explained in Fabulous Adventures in Data Structures and Algorithms

A node is an element in a graph or tree data structure that stores state and connects to related nodes through edges.

A node stores local state and connects to related nodes through labeled edges. In a trie, that state is whether a word ends here; outgoing edges map characters to successor nodes. Traversal proceeds from root to leaves, so parent references are unnecessary. section 5.2.1

A mutable node can expose operations such as checking an edge, following it, listing labels, and adding a successor. Keeping the dictionary private preserves the node-and-edge vocabulary and leaves the representation replaceable. section 5.2.1

Listing 5.2 A trie node
sealed class Node
{
    private readonly Dictionary<char, Node> edges = [];
    public bool IsEnd { get; set; }
    public IEnumerable<char> EdgeLabels => edges.Keys;
    public Node FollowEdge(char c) => edges [c]; #1
    public Node? TryFollowEdge(char c) =>  #2
        HasEdge(c) ? FollowEdge(c) : null;
    public bool HasEdge(char c) => edges.ContainsKey(c);
    public Node AddNewNode(char c) => edges [c] = new();
    public Node TryAddNewNode(char c) => 
        HasEdge(c) ? FollowEdge(c) : AddNewNode(c);
}

A compact C# implementation makes the node’s state, edge lookup, safe traversal, and incremental construction explicit. section 5.2.1

How Fabulous Adventures in Data Structures and Algorithms covers it

How deep it goes
Defines node state, edge representation, mutability, and accessor operations, stopping short of complete trie or DAWG algorithms.
Examples
Uses a C# Node class with IsEnd, EdgeLabels, FollowEdge, HasEdge, and node-creation operations.
What it assumes
Assumes familiarity with graph or tree structures and introduces the trie-specific state held by each node.
What you can do after
Build it from scratch by implementing a mutable trie node with encapsulated character-labeled edge operations.
How it connects
Connects nodes to tries, edges, words, root-to-leaf traversal, and directed acyclic word graphs.

Also explained in

Compare how 19 books explain node →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fabulous Adventures in Data Structures and Algorithms. The section links point to the parts of the book it draws on.