Skip to content
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

Data not present in pydot graph. #207

Open
lakhanjadhav1 opened this issue Mar 30, 2023 · 1 comment
Open

Data not present in pydot graph. #207

lakhanjadhav1 opened this issue Mar 30, 2023 · 1 comment
Labels
Bug Something isn't working

Comments

@lakhanjadhav1
Copy link

🐛 Bug I used pydotgraph_str = programl.to_dot(prog_graph) But I can see node labels only. No features information available in dot file.

To Reproduce

Steps to reproduce the behavior:

  1. Generate programl graph from any code
  2. Convert that graph to dot using programl.to_dot()
  3. That generated dot string doesn't have features info

Expected behavior

Environment

  • ProGraML version (if building from source, use git rev-parse HEAD):
  • How you installed ProGraML (source, pip):
  • OS:
  • Python version:
  • Build command you used (if building from source):
  • GCC/clang version (if building from source):
  • Bazel version (if building from source):
  • Versions of any other relevant libraries:

Additional context

@lakhanjadhav1 lakhanjadhav1 added the Bug Something isn't working label Mar 30, 2023
@ChrisCummins
Copy link
Owner

You're right, pg.to_dot(G) only adds the text of the node when exporting to dotfile.

Is there a specific feature you're looking to serialize?

You would need to modify this function and build from source to embed extra features:

template <typename T>
void SetVertexAttributes(const Node& node, T& attributes) {
attributes["label"] = GetNodeLabel(node);
attributes["style"] = "filled";
switch (node.type()) {
case Node::INSTRUCTION:
attributes["shape"] = "box";
attributes["fillcolor"] = "#3c78d8";
attributes["fontcolor"] = "#ffffff";
break;
case Node::VARIABLE:
attributes["shape"] = "ellipse";
attributes["fillcolor"] = "#f4cccc";
attributes["color"] = "#990000";
attributes["fontcolor"] = "#990000";
break;
case Node::CONSTANT:
attributes["shape"] = "octagon";
attributes["fillcolor"] = "#e99c9c";
attributes["color"] = "#990000";
attributes["fontcolor"] = "#990000";
break;
case Node::TYPE:
attributes["shape"] = "diamond";
attributes["fillcolor"] = "#cccccc";
attributes["color"] = "#cccccc";
attributes["fontcolor"] = "#222222";
break;
default:
LOG(FATAL) << "unreachable";
}
}

I could see that this would be generally useful. Patches welcome!

Cheers,
Chris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants