# Principle - Zettelkasten is a directed graph

In practice, a zettelkasten is a directed graph1 with some extra metadata in the form of tags. For example a very basic (read bad) implementation in 2 C++ could be.

#include <string>
#include <unordered_map>
#include <vector>

class Note
{
public:
std::string note_text;

{
}

private:
std::vector<std::string> tags;
};

class Zettelkasten
{
public:
void addNote(std::string id, Note& note) {notes[id] = note;};

std::vector<Note> findNotes(std::string keyword) { ... some search algo here ... };

Note& retrieveNote(std::string id) { return notes.at(id) };

{
auto note1 = notes.find(id1);
auto note2 = notes.find(id2);
if (note1 != notes.end() && note2 != notes.end())
{
}
}

// other methods to add and remove notes...

private:
std::unordered_map<std::string, Note> notes;
};

Boom, that easy! Using this as a base, we could implement a real (albeit clunky) Zettelkasten in code! I’ll leave neuron to do the heavy lifting on that front though.

1. This graph is not guaranteed to be acyclic. So we have to be careful about what inference we can run on the graph. In fact, if we view the zettelkasten as a model for the brain and human cognition, we may understand where “circular reasoning” comes from!

↩︎
2. I don’t expect anyone to actually implement this in C++. I’m convinced that C++ is not correct tool for the job. I was just able to whip this up quickly.

↩︎