零点课堂 | What Is a Directed Acyclic Graph (DAG) in Cryptocurrency?（2）
Conceptually, DAGs look something like the above. They're made up of vertices (the spheres) and the edges (the lines connecting them). They're directed because they head in one direction (you can see this illustrated with the arrows). They're acyclic (i.e., not cyclic) because the vertices don't loop back on themselves – if you start at one point and follow the graph, you can't return to that same point. This will become clearer shortly.
Such data structures are generally used to model data. You might rely on a DAG in scientific or medical fields to observe the relationship between variables and to determine how they impact each other. For instance, you could take things like nutrition, sleep cycles, and physical symptoms, so that you can draw links between them to establish how they affect a patient.
How does a DAG work?
In a DAG-based cryptocurrency, each vertex in the structure represents a transaction. There's no notion of blocks here, nor is mining required to extend the database. So instead of gathering transactions into blocks, each transaction is built on top of another. Still, there's a small Proof-of-Work operation that's done when a node submits a transaction. This ensures that the network isn't being spammed and also validates previous transactions.
For a new transaction to be added, it must build on top of older ones. Suppose that Alice creates a new transaction. For it to be acknowledged, this transaction must reference previous ones. A bit like how a block in Bitcoin references the one that came before it, but there are multiple transactions referenced.
In some systems, an algorithm will select which transactions (or "tips") a new transaction must build on. Tips more likely to be selected are those that have more accumulated weight – a measure of how many confirmations the path to the tip has.
The transactions that Alice will build on top of are unconfirmed. But once Alice references them, they become confirmed. Alice's transaction is now unconfirmed, so someone else must build on top of it before it's accepted.