Zettelkasten Forum


Grakn network visualization

Found this via @achamess's Google Group: http://grakn.ai/

At first glance, it looks like a pretty nice graph/visualization language (called "Graql"). But the "engine" can also deal with logical expressions (when X then Y) and infer information.

This is build for big data and genome analysis. But why shouldn't it produce some useful output when you feed it an analysis of your Zettelkasten?

I imagine this should work:

  • Traverse all notes;
  • collect all links ("forward" links) of the note and produce entity relations in Graql format;
  • produce a graph with Grakn.

You could vary the entity types and distinguish regular notes and structure notes to make the latter look different in the graph. You could also add all your tags to the graph, similar to the example below, as another entity (like "city") or as attributes (like "name"):

Maybe one can get fancy and add rules like "when a note is not connected to another note then it gets the "orphan" attribute". I bet you can do even more interesting things to group notes by similarity and proximity of tags, and see where one tag cluster crosses its boundaries and links to another cluster's note, or whatever.

Or maybe not! :) I don't have a clue, yet, but since I cannot play with this for quite some time, I thought you folks might want to.

Author at Zettelkasten.de • http://christiantietze.de/

Comments

  • I briefly played with making a visualization like this using dot language, but this looks much more extensible than my probably-never-actually-realized idea.

  • edited February 20

    Not too hard to make a gephi-file as well to play with graphs. If you just make a script that searches all files for IDs and make a new line for each hit you can easily convert to many formats.

    Dot example:
    201712180005 -> 201801241152

    Gephi example:
    <edge id="606" source="201712180005" target="201801241152" />

    Also @EFLS use in Zetteldeft
    https://efls.github.io/zetteldeft/#orgdc68570

  • Oh right! I always forget that he put that in there.

  • I read this post over lunch and thought it'd be fun to visualize @ctietze 's ba-zettelkasten-justice-for-hedgehogs notes.

    I wrote a Python script to scan the notes folder, parse the zettel IDs, titles, and links, and build the network using the Python graphviz package. The results looks like this:

    I've also attached a PDF version, if you'd like to zoom in, as well as the script itself. You'll need to change the extension to .py, and to install Graphviz (the tool) and graphviz (the Python package). It's not super flexible but it has some options:

    $ python zk_network_viz.py --help
    usage: zk_network_viz.py [-h] [--notes-dir NOTES_DIR] [--output OUTPUT]
                             [--style {record,plaintext}] [--pattern PATTERN]
                             [--layout {circo,dot,fdp,neato,osage,patchwork,sfdp,twopi}]
    
    Visualize the notes network of a Zettelkasten. Each arrow represents a link
    from one zettel to another. The script assumes that zettels have filenames of
    the form "YYYYMMDDHHMM This is a title" and that links have the form
    [[YYYYMMDDHHMM]]
    
    optional arguments:
      -h, --help            show this help message and exit
      --notes-dir NOTES_DIR
                            path to folder containin notes. [default: .]
      --output OUTPUT       name of output file. [default: zettel-network]
      --style {record,plaintext}
                            style of each node. [default: record]
      --pattern PATTERN     pattern to match notes. [default: *.md]
      --layout {circo,dot,fdp,neato,osage,patchwork,sfdp,twopi}
                            layout engine used by graphviz. [default: sfdp]
    

    If there's some interest, I could turn this into a pip-installable package.

  • Really cool! I like it!
    Now, it would be cool to find a way to label and specify those relations. But the visualization is very interesting. Thanks for doing this!

    @alexchabot said:
    I read this post over lunch and thought it'd be fun to visualize @ctietze 's ba-zettelkasten-justice-for-hedgehogs notes.

    I wrote a Python script to scan the notes folder, parse the zettel IDs, titles, and links, and build the network using the Python graphviz package. The results looks like this:

    I've also attached a PDF version, if you'd like to zoom in, as well as the script itself. You'll need to change the extension to .py, and to install Graphviz (the tool) and graphviz (the Python package). It's not super flexible but it has some options:

    $ python zk_network_viz.py --help
    usage: zk_network_viz.py [-h] [--notes-dir NOTES_DIR] [--output OUTPUT]
                             [--style {record,plaintext}] [--pattern PATTERN]
                             [--layout {circo,dot,fdp,neato,osage,patchwork,sfdp,twopi}]
    
    Visualize the notes network of a Zettelkasten. Each arrow represents a link
    from one zettel to another. The script assumes that zettels have filenames of
    the form "YYYYMMDDHHMM This is a title" and that links have the form
    [[YYYYMMDDHHMM]]
    
    optional arguments:
      -h, --help            show this help message and exit
      --notes-dir NOTES_DIR
                            path to folder containin notes. [default: .]
      --output OUTPUT       name of output file. [default: zettel-network]
      --style {record,plaintext}
                            style of each node. [default: record]
      --pattern PATTERN     pattern to match notes. [default: *.md]
      --layout {circo,dot,fdp,neato,osage,patchwork,sfdp,twopi}
                            layout engine used by graphviz. [default: sfdp]
    

    If there's some interest, I could turn this into a pip-installable package.

  • @achamess What would you label the links with? With markdown links, I could use the link’s text, but there’s no other info in the wiki links. Maybe something taken from the source file?

  • This looks very interesting, thanks @alexchabot for trying and posting this! I would love to have the opportunity to create such a graph from a selected set of notes. Ideally this would be possible with the selection of notes that shows in the sidebar of The Archive after I've searched for something – that makes it easier to get an overview over existing notes on something and to find existing and missing connections between a set of notes.
    What would I need to do in order to make that happen? How do I use the script you posted? Could it for example be a macro in Keyboard Maestro, activated by a keyboard shortcut?
    As far as I understand, I need to install Homebrew or MacPorts to install Graphviz. I guess I also need to download Python. Is there an easier way to get this visualisation without your script and having to download all these things (that I don't have any other use for at the moment)? Any (free) app that does this maybe?

  • @Vinho Those are great ideas. It'd definitely be possible to trigger the script from KeyboardMaestro. I'd need to look into getting the list of selected files from The Archive to create the graph, but I assume it's possible. I created an issue in the repo where I'll be sharing the code.

    You don't need to install Python, because it comes standard on the Mac, but I used a third-party packages to create the graph because that's what what easiest. As for Graphviz itself, it does look like it's must be installed with Homebrew of Macports (I recommend Homebrew) and there isn't much I can do about that. I don't know of a pure-Python library that can easily make such graphs.

  • @alexchabot Getting the list of selected files could work by scripting against the Accessiblity identifiers of the UI components -- it will be easier once I add a proper AppleScript dictionary later this year.

    Author at Zettelkasten.de • http://christiantietze.de/

  • @alexchabot: Would be awesome if that could work. With all these Keyboard Maestro macros The Archive is an incredibly powerful tool...

  • edited March 29

    What I would be almost equally happy with and might be easier to implement is the possibility to create such graphs for tags (enter a tag and a network-graph is created for all the notes with that tag).

  • I would vote for a pip install! Not to give you more work but just to show my interest and support for this great execution of the idea!

  • It’ll definitely be pip-installable. But i need to figure out if there’s a sane way to make their network graphs without graphviz. Otherwise, graphviz will need to be installed separately (which is a pain). I’m looking into using NetworkX and matplotlib, which should be ok for small graphs.

  • @alexchabot: Any news? If I could help with this in any way I would, but unfortunately my few programming skills won’t be of much use...

  • @Vinho I've not abandoned! But you know, life got in the way. I just finished working on a version that uses plot.ly instead of Graphviz, which means it'll be much easier to install and we'll get interactivity for free! I'll try to publish it this weekend, but it might have to wait to the weekend after that.

  • @alexchabot Great, very much looking forward to it!

  • zkviz is live! See the announcement post for more details.

Sign In or Register to comment.