.. Autogenerated in conf.py .. _examples-basics: .. _examples-000_basics: Basics, Graphs, and Rules ################################################################################ Graph Interface ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Graph objects have a full interface to access individual vertices and edges. The attributes of vertices and edges can be accessed both in their raw string form, and as their chemical counterpart (if they have one). `Explore in the playground `__. .. literalinclude:: /_static/examples/py/000_basics/012_graphInterface.py :language: python :linenos: :lines: 1-18 :tab-width: 3 Formose Grammar ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The graph grammar modelling the formose chemistry. `Explore in the playground `__. .. literalinclude:: /_static/examples/py/000_basics/050_formoseGrammar.py :language: python :linenos: :lines: 1-50 :tab-width: 3 Printing Graphs/Molecules ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The visualisation of graphs can be "prettified" using special printing options. The changes can make the graphs look like normal molecule visualisations. `Explore in the playground `__. .. literalinclude:: /_static/examples/py/000_basics/011_graphPrinting.py :language: python :linenos: :lines: 1-29 :tab-width: 3 Including Files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ We can include other files (a la C/C++) to separate functionality. `Explore in the playground `__. .. literalinclude:: /_static/examples/py/000_basics/051_fileInclusion.py :language: python :linenos: :lines: 1-7 :tab-width: 3 Graph Loading ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Molecules are encoded as attributed graphs. They can be loaded from SMILES strings, and in general any graph can be loaded from a GML specification, or from the SMILES-like format GraphDFS. `Explore in the playground `__. .. literalinclude:: /_static/examples/py/000_basics/010_graphLoading.py :language: python :linenos: :lines: 1-35 :tab-width: 3 Hello World ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ These examples use the Python 3 interface for the software. After each run a PDF summary is compiled. The content can be specified via the Python script. `Explore in the playground `__. .. literalinclude:: /_static/examples/py/000_basics/000_hello.py :language: python :linenos: :lines: 1-9 :tab-width: 3 Graph Morphisms ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Graph objects have methods for finding morphisms with the VF2 algorithms for isomorphism and monomorphism. We can therefore easily detect isomorphic graphs, count automorphisms, and search for substructures. `Explore in the playground `__. .. literalinclude:: /_static/examples/py/000_basics/013_graphMorphisms.py :language: python :linenos: :lines: 1-20 :tab-width: 3 Rule Loading ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Rules must be specified in GML format. `Explore in the playground `__. .. literalinclude:: /_static/examples/py/000_basics/030_ruleLoading.py :language: python :linenos: :lines: 1-68 :tab-width: 3 Rule Morphisms ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Rule objects, like graph objects, have methods for finding morphisms with the VF2 algorithms for isomorphism and monomorphism. We can therefore easily detect isomorphic rules, and decide if one rule is at least as specific/general as another. `Explore in the playground `__. .. literalinclude:: /_static/examples/py/000_basics/031_ruleMorphisms.py :language: python :linenos: :lines: 1-34 :tab-width: 3