Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

A static analysis library for computing graph representations of Python programs suitable for use with graph neural networks.

License

Notifications You must be signed in to change notification settings

google-research/python-graphs

Repository files navigation

python_graphs

This package is for computing graph representations of Python programs for machine learning applications. It includes the following modules:

  • control_flow For computing control flow graphs statically from Python programs.
  • data_flow For computing data flow analyses of Python programs.
  • program_graph For computing graphs statically to represent arbitrary Python programs or functions.
  • cyclomatic_complexity For computing the cyclomatic complexity of a Python function.

Installation

To install python_graphs with pip, run: pip install python_graphs.

To install python_graphs from source, run: python setup.py develop.

Common Tasks

Generate a control flow graph from a function fn:

frompython_graphsimportcontrol_flowgraph=control_flow.get_control_flow_graph(fn)

Generate a program graph from a function fn:

frompython_graphsimportprogram_graphgraph=program_graph.get_program_graph(fn)

Compute the cyclomatic complexity of a function fn:

frompython_graphsimportcontrol_flowfrompython_graphsimportcyclomatic_complexitygraph=control_flow.get_control_flow_graph(fn) value=cyclomatic_complexity.cyclomatic_complexity(graph)

This is not an officially supported Google product.

About

A static analysis library for computing graph representations of Python programs suitable for use with graph neural networks.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages