New 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
Add --graphml option to the nix-store --query command #2479
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! Look forward to trying it out :). Made a pass with some suggestions/comments.
src/nix-store/graphml.cc
Outdated
|
||
static string makeEdge(const string & src, const string & dst) | ||
{ | ||
format f = format(" <edge source=\"%1%\" target=\"%2%\"/>\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe return fmt(..., xmlQuote(src), xmlQuote(dst));
? Saves the need for calling f.str()
.
src/nix-store/graphml.cc
Outdated
workList.erase(path); | ||
|
||
if (doneSet.find(path) != doneSet.end()) continue; | ||
doneSet.insert(path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe check the return value of insert instead (.second
)? Shorter and saves searching again for the insert.
|
||
for (auto & p : store->queryPathInfo(path)->references) { | ||
if (p != path) { | ||
workList.insert(p); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a std::set for the worklist might not be the best, and seems like would have an unusual ordering, niether BFS nor DFS but ... alphabetically (of the current worklist)? If so, I imagine it doesn't matter to tools reading it but might annoy or confuse someone inspecting it by hand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it's really useful to make the code more complex to have a more xml
human readable file (the goal of this PR is to generate a file that can be easily parsed by several tools).
I wonder why the set of paths is ordered while there is an unordered_set
container in the std lib (I have a patch that uses an unordered_set
in this file that I could include if it is pertinent).
Yeah I think it's fine to replace |
I'll add docs and remove |
This prints the references graph of the store paths in the graphML format [1]. The graphML format is supported by several graph tools such as the Python Networkx library or the Apache Thinkerpop project. [1] http://graphml.graphdrawing.org
The `--graphml` option can be used instead.
I've added docs and removed @dtzWill FYI, I'm using this option with https://github.com/nlewo/gremnix :) |
This prints the references graph of the store paths in the graphML
format [1]. The graphML format is supported by several graph tools
such as the Python Networkx library or the Apache Thinkerpop project.
I also wonder if this could replace the
--xml
output since the GraphML format is well known and easy to manually parse.[1] http://graphml.graphdrawing.org