Skip to content

Commit

Permalink
Merge branch 'features'
Browse files Browse the repository at this point in the history
  • Loading branch information
aatmunbaxi committed Dec 31, 2023
2 parents 5c59738 + 5e2bc0a commit b776ca7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions orgroamtools/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,26 @@ def math_snippet_index(self) -> dict[str, list[str]]:
"""
return {node.id: extract_math_snippets(node.body) for node in self.nodes}

@property
def adjacency_list(self) -> list[list[str]]:
"""Return adjacency list of collection
An adjacency list is a (sometimes) more memory-efficient
way to store the information of a graph. It stores edges of the
graph instead of correspondences of nodes in a matrix for example.
If a node ``a`` has an edge pointing to node ``b``, the pair ``[a,b]``
will appear in the adjacency list. Keeping with the theme of this
library, the node identifiers will be used to identify the nodes.
All nodes will appear in the list, since by convention, an org-roam
node always links to itself.
Returns
-------
``list[list[str]]``
Adjacency list of collection with node IDs to identify nodes
"""
return [[node.id, other] for node in self.nodes for other in node.backlinks]

def get_latex_snippets(self, identifier: str) -> list[str]:
"""Return latex snippets of node
Expand Down

0 comments on commit b776ca7

Please sign in to comment.