SkepticMystic / adjacency-matrix-maker Public
generated from obsidianmd/obsidian-sample-pluginNew issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request : Save adjacency matrix in a standard data table/format ? #4
Comments
|
@woodoxherd hey :) const { resolvedLinks } = app.metadataCache
const filePaths = Object.keys(resolvedLinks)
const adjMatrix = {}
filePaths.forEach(pathI => {
adjMatrix[pathI] = {}
filePaths.forEach(pathJ => {
const degree = resolvedLinks[pathI][pathJ] ?? 0
adjMatrix[pathI][pathJ] = degree
})
})
console.log(JSON.stringify(adjMatrix)) |
|
You could then run that JSON object thru this converter to get it to CSV: https://www.convertcsv.com/json-to-csv.htm |
|
Hey @SkepticMystic ! I turned the example above as a new vault in order to try out your snippet, but it seems not to work, as you can see. Maybe that is nothing, maybe i did something wrong ? |
|
Here is the vault i used, in case you would need it for some debugging : Adjacency Test.zip |
|
It looks like it ran fine the first time you called it. You can need to run But you'll see that calling it again will give the Duplicate Identifier error. That's because the snippet declares it's variables as |
|
Ok Ross @SkepticMystic thanks, i think i managed my way out of this. \°/ So, for posterity, if ever someone with the same needs than me would land on this page, i used In our example, it returns some beautiful raw stuffs :
Then, just copy this output given by the console, and, after a slight move through Regexr (for instance) in order to eliminate all the ".md", paste everything into the ConvertCSV mentioned above. Et Voilà : adjmatrixtest.csv ! :) |
|
Nice! |
|
@SkepticMystic Just as a an opening, a doorway : Would you have at your Knowledge some existing code already done that could process in the other way, i.e., starting from the CSV in order to build the Vault in Obsidian (with a template option, eventually) ?? As i intend to apply some matrix multiplication to the adjMatrix we got, that would be a convenient (and error less) way to vizualise the result back into Obsidian, compared to what i did by hand for our example above. Please, let me know if ever you have references on this, please, and have a good One ! |

Hi SkepticMystic,
Recently, i runned a Google research with "adjacency matrix" and "Obsidian" as keywords, and naturally stumble on this plugin of yours, which i missed into the app plugin browser : Thanks for making this feature available, this is very interesting !
As i would need it quite soon in the near future, for professional foresight use, my initial research was to know if there would be a way to convert an Obsidian graph into an adjacency matrix.. but the latter one having numbers instead of colors :)
i.e. from something like this:
to something like this:
Would you think this could be quite quickly implementable into the Save options of your plugin, like into .csv or some standard equivalent ??
Thanks for your feedback, and have a good One,
Damien
The text was updated successfully, but these errors were encountered: