Skip to main content

Plugin for CRIPT Python SDK, convert CRIPT graphs to networkx graphs and dot graphs for vizualization.

Project description

CRIPT Graph Operation Plugin for the Python SDK

CI Tests https://trunk.io check

This repository contains a plugin designed to work with the Python SDK of the CRIPT project. The CRIPT project is an innovative initiative in polymer technology. For more information about the project, please visit the CRIPT website.

The Python SDK, which this plugin complements, can be found here. It provides a powerful set of tools for working with CRIPT data graphs.

Installation

To install the CRIPT Graph Operation Plugin, you can use pip:

pip install cript-graph

NetworkX Graph Conversion

The plugin offers a convenient conversion function to convert a CRIPT SDK data graph into a NetworkX graph. NetworkX is a widely-used Python package for graph operations.

Here's an example of how to use the conversion function:

import cript
import cript_graph

with cript.API(None, None) as api:
    # CRIPT SDK code to build or download the data graph
    project = cript.Project(...)
    # ...
    networkx_graph = cript_graph.get_networkx_graph(project)
    # Perform NetworkX graph operations
    print(networkx_graph.nodes)
    print(networkx_graph.edges)

Please refer to the documentation of the get_networkx_graph function for detailed information about the resulting graph.

Graphviz Dot Visualization

Visualizing the entire data graph of CRIPT can sometimes be challenging, especially when more detailed information is required, such as for debugging purposes. In such cases, the Graphviz dot tool can be a valuable resource.

The plugin provides a tool to generate a visual representation of the data graph using the Graphviz dot language.

Here's an example of how to generate a dot file using the plugin:

import cript
import cript_graph

with cript.API(None, None) as api:
    # CRIPT SDK code to build or download the data graph
    project = cript.Project(...)
    # ...
    # Create an intermediate NetworkX graph
    networkx_graph = cript_graph.get_networkx_graph(project)
    # Generate the graph representation in the dot language
    dot_string = cript_graph.get_dot_graph(networkx_graph)

You can write the resulting dot language string to a file:

with open("graph.dot", "w") as file_handle:
    file_handle.write(dot_string)

To convert the dot file to an SVG graph using the Graphviz command line tool:

dot -Tsvg graph.dot > graph.svg

Alternatively, you can use the pydot package to handle the generation of the visualization from within Python:

import pydot

pydot_graph = pydot.graph_from_dot_data(dot_string)
pydot_graph.write_svg("graph.svg")

An example graph of CRIPT visualized using Graphviz dot:

Example Graph of CRIPT visualized via Graphviz dot

References

Walsh, D. J., Zou, W., Schneider, L., Mello, R., Deagen, M. E., Mysona, J., ... & Olsen, B. D. (2023). Community Resource for Innovation in Polymer Technology (CRIPT): A Scalable Polymer Material Data Structure.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cript_graph-0.0.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cript_graph-0.0.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file cript_graph-0.0.0.tar.gz.

File metadata

  • Download URL: cript_graph-0.0.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for cript_graph-0.0.0.tar.gz
Algorithm Hash digest
SHA256 0d6d5bdd01f4fe140824108fa63cee63c0e06dfea0c0a66a1098f151ac9471e7
MD5 570777948ba46c4e8ee9d45e245e2919
BLAKE2b-256 3782ea693f0a63d95162a14132ba8ed619013392eae69b8e84f7e0faf7427982

See more details on using hashes here.

File details

Details for the file cript_graph-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: cript_graph-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for cript_graph-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb26fef931bb66ebd83aa0af1336df274a8440069f68b680e23bc54132e21963
MD5 04a3312ca6eaf0c67399e36afafe479a
BLAKE2b-256 e4a40f8189bc2a22fab8cbf74a5bef6d335c27d8680cc6d32dcffd7bc5563789

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page