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

Schema visualization tool #340

Open
post2web opened this issue Feb 24, 2023 · 0 comments
Open

Schema visualization tool #340

post2web opened this issue Feb 24, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@post2web
Copy link

Schemas can be complex and need visualization. A simple script could convert the schema to a networkx graph and generate an image with the graph visualization.

This can be a starting point:

import networkx as nx
import matplotlib.pyplot as plt


graph_schema = tfgnn.read_schema("schema.pbtxt")
graph = nx.DiGraph()

nodes = [
    name for name in graph_schema.node_sets.keys()
]
edges = [
    [e.source, e.target] for e in graph_schema.edge_sets.values()
]
edge_labels = {
    (e.source, e.target): name for name, e in graph_schema.edge_sets.items()
}

graph.add_nodes_from(nodes)
graph.add_edges_from(edges)

pos = nx.spring_layout(graph)

nx.draw(graph,
        pos=pos,
        node_size=1000,
        with_labels = True)

nx.draw_networkx_edge_labels(
    graph,
    pos=pos,
    edge_labels=edge_labels
)

plt.savefig("schema.png")

The above can generate a schema visualizations like this:
Unknown

@arnoegw arnoegw added the enhancement New feature or request label Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants