Skip to main content

A collection of algorithms for cycles in a graph.

Project description

cycless

A collection of algorithms to analyze a graph as a set of cycles.

Some codes come from https://github.com/vitroid/Polyhed and https://github.com/vitroid/countrings are integrated and improved.

API

API manual is here.

Cycles

A simple algorithm to enumerate all irreducible cycles of n-members and smaller in an undirected graph. [Matsumoto 2007]

import cycless.cycles as cy
import networkx as nx

g = nx.cubical_graph()

for cycle in cy.cycles_iter(g, maxsize=6):
    print(cycle)

Counting policy

  • It counts only irreducible rings (rings not having shortcut bridges).
  • It counts rings purely topologically. It does not use geometrical information.
  • Edge direction is not considered. (Undirected graph)

Algorithm

  1. Choose 3 successive nodes (i.e. two adjacent acyclic edges) along the network. (King's criteria) [King1991]
  2. Find the smallest rings passing the three nodes.
  3. The ring must not have shotcuts, i.e. path connecting two vertices on the ring which is shorter than the path along the ring. (Using Dijkstra's algorithm.) (Franzblau's SP ring criteria) [Franzblau1991]
  4. Put the ring in the list.
  5. Repeat 1 .. 4 until all sets of 3 successive nodes are tested.
  6. Eliminate the permutations of a ring in the list.
  7. (Optional) Remove "crossing rings".

So, our definition is a hybrid of the algorithms of King and Franzblau.

Note

  • Our definition is different from Franzblau's SP ring. Our algorithm does not count the 6-membered rings in a cubic graph but counts the geodesic 4-membered rings in a regular octahedral graph. [Franzblau1991]
  • Our definition is different from King's K ring. [King1991]
  • Our definition is different from Goetzke's strong ring. We do not care the strength. [Goetzke1991]
  • Our definition is different from that of Camisasca's. They count too much 5-membered rings. [Camisasca2019]
  • Probably somebody has already made the same definition. Let me know if you find that.

To Cite It

  • M. Matsumoto, A. Baba, and I. Ohmine, Topological building blocks of hydrogen bond network in water, J. Chem. Phys. 127, 134504 (2007); doi:10.1063/1.2772627

Dicycles

An algorithm to enumerate the directed cycles of a size in a dircted graph. [Matsumoto 2021]

from genice2.genice import GenIce
from genice2.plugin import Lattice, Format, Molecule
import cycless.dicycles as dc

# Generate an ice I structure as a directed graph
lattice = Lattice("1h")
formatter = Format("raw", stage=(4,))
raw = GenIce(lattice, signature="ice 1h", rep=[2, 2, 2]).generate_ice(formatter)
print(raw["digraph"])

for cycle in dc.dicycles_iter(raw["digraph"], size=6):
    print(cycle)

To Cite It

  • Matsumoto, M., Yagasaki, T. & Tanaka, H. On the anomalous homogeneity of hydrogen-disordered ice and its origin. J. Chem. Phys. 155, 164502 (2021); doi:10.1063/5.0065215

Polyhed

An algorithm to enumerate the quasi-polyhedral hull made of cycles in an undirected graph. A quasi-polyhedral hull (vitrite) obeys the following conditions: [Matsumoto 2007]

  1. The surface of the hull is made of irreducible cycles.
  2. Two or three cycles shares a vertex of the hull.
  3. Two cycles shares an edge of the hull.
  4. Its Euler index (F-E+V) is two.
import cycless.cycles as cy
import cycless.polyhed as ph
import networkx as nx

g = nx.dodecahedral_graph()

cycles = [cycle for cycle in cy.cycles_iter(g, maxsize=6)]
for polyhed in ph.polyhedra_iter(cycles):
    print(polyhed)

To Cite It

  • M. Matsumoto, A. Baba, and I. Ohmine, Topological building blocks of hydrogen bond network in water, J. Chem. Phys. 127, 134504 (2007); doi:10.1063/1.2772627

Simplex

Enumerate triangle, tetrahedral, and octahedral subgraphs found in the given graph.

Rings

In this module, a directed graph whose underlying undirected graph is a cycle is defined as a Ring. Along the ring, a bit string representing whether each directed edge is oriented forward or backward is defined as a code. rings.py provides a set of functions for computing statistics of codes.

from genice2.genice import GenIce
from genice2.plugin import Lattice, Format, Molecule
from cycless.rings import rings_iter

# Generate an ice I structure as a directed graph
lattice = Lattice("1h")
formatter = Format("raw", stage=(4,))
raw = GenIce(lattice, signature="ice 1h", rep=[2, 2, 2]).generate_ice(formatter)

for ring in rings_iter(raw["digraph"], maxsize=6):
    print(ring)

To Cite It

  • Matsumoto, M., Yagasaki, T. & Tanaka, H. GenIce-core: Efficient algorithm for generation of hydrogen-disordered ice structures. J. Chem. Phys. 160, 094101 (2024).

References

  • Camisasca, G., Schlesinger, D., Zhovtobriukh, I., Pitsevich, G. & Pettersson, L. G. M. A proposal for the structure of high- and low-density fluctuations in liquid water. J. Chem. Phys. 151, 034508 (2019).
  • Downs, G. M., Gillet, V. J., Holliday, J. D. & Lynch, M. F. Review of ring perception algorithms for chemical graphs. J. Chem. Inf. Comput. Sci. 29, 172–187 (1989).
  • Franzblau, D. S. Computation of ring statistics for network models of solids. Phys. Rev. B 44, 4925–4930 (1991).
  • Goetzke, K. & Klein, H. J. Properties and efficient algorithmic determination of different classes of rings in finite and infinite polyhedral networks. J. Non-Cryst. Solids. 127, 215–220 (1991).
  • KING, S. V. Ring Configurations in a Random Network Model of Vitreous Silica. Nature 213, 1112–1113 (1967).
  • Marians, C. S. & Hobbs, L. W. Network properties of crystalline polymorphs of silica. J. Non-Cryst. Solids. 124, 242–253 (1990).
  • M. Matsumoto, A. Baba, and I. Ohmine, Topological building blocks of hydrogen bond network in water, J. Chem. Phys. 127, 134504 (2007). http://doi.org/10.1063/1.2772627
  • Matsumoto, M., Yagasaki, T. & Tanaka, H. On the anomalous homogeneity of hydrogen-disordered ice and its origin. J. Chem. Phys. 155, 164502 (2021). https://doi.org/10.1063/5.0065215
  • Matsumoto, M., Yagasaki, T. & Tanaka, H. GenIce-core: Efficient algorithm for generation of hydrogen-disordered ice structures. J. Chem. Phys. 160, 094101 (2024).

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

cycless-0.6.5.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

cycless-0.6.5-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file cycless-0.6.5.tar.gz.

File metadata

  • Download URL: cycless-0.6.5.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.11 Darwin/24.5.0

File hashes

Hashes for cycless-0.6.5.tar.gz
Algorithm Hash digest
SHA256 37a6396a870a3565203b79acdfc507ee8faefe39870f6797174ecf00c36e2bd6
MD5 83d56e7c441c1857bea33bf212ad9a78
BLAKE2b-256 784bfdae14b9836a4314b9a8cf31701c2c1bf2e6e161d0f700cf600a5d734e61

See more details on using hashes here.

File details

Details for the file cycless-0.6.5-py3-none-any.whl.

File metadata

  • Download URL: cycless-0.6.5-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.11 Darwin/24.5.0

File hashes

Hashes for cycless-0.6.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cbbb417119157da17179837616090042aa00236f33824bc98c0adafbfa4cc111
MD5 f1610ff6a9db2d0c805c52a5a4a1d5e3
BLAKE2b-256 061ce9f28ea31599d3b06ab511a5ceac7d6de12a61ec011a20953d4b3170a10d

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