Skip to main content

cycle_analysis module, performing minimal cycle basis calculation and the cycle coalescecne algorithm.

Project description

cycle-coalescence-algorithm

Have you ever wondered how cycles in graphs form a vector space and encapsulate nesting information? Here is a tool ready to use, enabling you to calculate the cycle bases, mapping them onto a merging tree, and analyze this tree's asymmetry.

Introduction

This python module allows users to analyze weighted, undirected simple graphs for their nested cycle structure by performing two major functions: Calculating minimal cycle bases (Horton algorithm) and computing the merging tree (cycle coalescence algorithm). The algorithm is described in "Modes et al,'Extracting Hidden Hierarchies in 3D Distribution Networks', 2016" and basically follows the shown scheme below:

  • All fundamentals minimal cyles (minimal number of edges) are listed in the weighted graph G and mapped onto the leaves of a new tree T.
  • Then one identifies the lightest edge e in G and merges the two smallest cycles along this edge, creating a new vertex in the tree T for the merger cycle
  • remove the original two cycles and proceed with the next lightest edge e until all cycles in G are merged
  • finally calculate the tree asymmetry using the techniques of "Van-Pelt et al, 'Tree Asymmetry—A Sensitive and Practical Measure for Binary Topological Trees' ,1992"
  • the asymmetry orderparameter will be be 1 for perfecly asymmetric trees and 0 for perfectly symmetric trees modes Figure taken from: Modes et al,'Extracting Hidden Hierarchies in 3D Distribution Networks', 2016

Installation

pip install cycle_analysis

Usage

Currently this implementation only supports networkx graphs. Call cycle_analysis.cycle_coalescence for graph analysis, while cycle_analysis.test provides you with pre-customized functions to put specific weight patterns onto the graph: random/gradient/nested_square

import networkx as nx
import cycle_analysis.cycle_coalescence as cc
import cycle_analysis.cycle_custom_pattern as ccp

# generate a dummy graph for testing
# put an edge weight distribution on the system, available are random/gradient/nested_square
G=nx.grid_graph((7,7,1))
G=ccp.generate_pattern(G,'nested_square')

# merge all shortest cycles and calc the merging tree's asymmetry for each branch
asymmetry=cc.calc_cycle_asymmetry(G)
print(asymmetry)

./notebook contains examples to play with in the form of jupyter notebooks

Requirements

python3.6+,networkx, numpy

Gallery

random weight distribution
random

nested square weight distribution
nested

gradient weight distribution
gradient

Acknowledgement

cycle_analysis written by Felix Kramer

This implementation is based on the cycle coalescence algorithm as described by Modes et al, 2016. Please acknowledge if used for any further publication or projects.

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

cycle_analysis-0.0.5.tar.gz (8.4 kB view details)

Uploaded Source

File details

Details for the file cycle_analysis-0.0.5.tar.gz.

File metadata

  • Download URL: cycle_analysis-0.0.5.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

File hashes

Hashes for cycle_analysis-0.0.5.tar.gz
Algorithm Hash digest
SHA256 bcd7d815d8acb38e3a0ab036b13ef67b2b6f2d30b23b7d2526e1f052abb850e8
MD5 884c4f099e03f3eba215256d8c5c4663
BLAKE2b-256 7638fb02896f121d052cf8f45507657a9ffd16ada12a2be9d0e1fc28ca782548

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