Graph-plotting module

class xettel.graph.ZKGraph

Class for handling graph-related operation on a Zettelkasten

The __init__ method only initialises self.nxgraph.

nxgraph

networkx graph built from a Zettelkasten

pgvgraph

pygraphviz graph built from self.nxgraph

zk

Zettelkasten from which the nxgraph is built.

draw_graph(path: str) None
Draws the graph using graphviz to the specified path

with desired extension

Parameters

path (str) – the path to write to.

export_to_cytoscape() str

Exports a JSON dictionnary for use with Cytoscape.js

classmethod from_zettelkasten(zk: ZettelkastenAbstract) ZKGraph

Builds a networkx graph from an initialised zettelkasten

Parameters

zk (ZettelkastenAbstract) – a Zettelkasten

Returns

An instance of this class with self.nxgraph properly initialised.

initialise_graphviz() None

Converts networkx graph to a pygraphviz graph

initialise_nx_graph_from_zk() None

Initialises a networkx graph from a Zettelkasten. Assumes that the Zettelkasten has been properly initialised.

is_connected() bool

Tests is graph fron Zettelkasten is weakly connected. Assumes that the nx graph has already been initialised.

Returns

A boolean, True if the nxgraph is weakly connected.

set_graphviz_labels() None

Sets labels to graphviz graph for export

set_graphviz_layout(program: str = 'neato', model: str = 'circuit') None

Runs the graphviz’s program to lay out the nodes accordingly

Keyword Arguments
  • program (str) – the program to use

  • model (str) – the model to use

set_graphviz_layout_attributes() None

Sets attributes to individual edges and nodes prior to running the layout

unconnected_zettels_uids() set[int]

Returns a set of zettels uid which are not in the same weakly connected component as ‘0’.

Returns

A set of uids of Zettels not connected to the root.

xettel.graph.name(uid: int, zk: ZettelkastenAbstract) str

Extract raw name of the zettel

Parameters
Returns

Basename of the Zettel

xettel.graph.url(uid: int, zk: ZettelkastenAbstract) str

Gives the url the graph’s nodes should point to

Parameters
Returns

Path to the export url of the Zettel (only html implemented so far).