Skip to main content

Module for a lightweight LWWElementGraph

Project description

Welcome to LWWElementGraph’s documentation!

LWWElementGraph

Module for a lightweight LWWElementGraph, which uses LWWElementSet. Handles merges in a Last Write Wins Manner.

LWWElementSet

Module for a lightweight LWWElementSet in Python. Handles merges in a Last Write Wins Manner.

Install

To install packages, perform: pip install -r requirements.txt

Tests

  • /tests/testLWWElementSet.py
  • /tests/testLWWElementGraph.py
  • /tests/testIntegration.py

Contents:

LWWElementGraph package

Module contents

class LWWElementGraph.LWWElementGraph()

Bases: object

_init_()

Initializing Vertices and Edges as LWWElementSet. Maintaining live updating graphState to optimize reads (getNeighborsOf, findPath)

addEdge(vertex1, vertex2)

If vertex1, vertex2 present, add edge to edges.addSet. Maintain graphState Runs in O(1)

addVertex(vertex)

Adds the Vertex to vertices LWWSet. Also maintains graphState for read optimization Runs in O(1)

findPath(vertex1, vertex2)

Perform BFS for shortest path. Uses graphState which was optimized for read to get all the neighbours of a vertex in O(1). Runs in O(V + E)

getNeighborsOf(vertex)

O(1) query for all the vertices connected to the query vertex. Uses graphState which was optimized for read

isMember(vertex)

Check if vertex is valid, runs in O(1)

mergeGraphs(otherGraph)

Merging Graphs by merging their Vertice and Edge LLWSet. Remove Edge if Vertex not present anymore after merge. Recompute the internal graphState as well. Runs in O(V + E)

removeEdge(vertex1, vertex2)

If edge present, add it to edges.removeSet. Maintain graphState. Runs in O(E) because of _removeEdge

removeVertex(vertex)

If vertex is present, then add it to vertices.removeSet. Add each of its edge to edges.removeSet. Also maintains graphState for read optimization. Runs in O(E) because of _removeVertex

Submodules

LWWElementGraph.LWWElementSet module

class LWWElementGraph.LWWElementSet.LWWElementSet()

Bases: object

_init_()

Initialize addSet and removeSet to empty dictionary. iData and iTimestamp are the index of the data and timestamp respectively

addElement(element)

Adds in the addSet. If element already in addSet, replace timestamp with now()

getMembers()

Returns all the valid members. Go through addSet, check if it is a member

isMember(element)

Element is a member if it is in addSet, and either not removeSet, or in removeSet but with an earlier timestamp than it’s timestamp in addSet

mergeSet(selfSet, otherSet)

Prioritize Last Write. Since elements are in the form (data, datetime), reverse them to compare by datetime and take max. Then, reverse back the max and store in merged

mergeWith(otherLWWElementSet)

Merge self with otherLWWElementSet in LWW manner

removeElement(element)

Adds in the removeSet. Cannot remove if not already in addSet


Made by krohak

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

LWWElementGraph-1.0.5.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

LWWElementGraph-1.0.5-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file LWWElementGraph-1.0.5.tar.gz.

File metadata

  • Download URL: LWWElementGraph-1.0.5.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for LWWElementGraph-1.0.5.tar.gz
Algorithm Hash digest
SHA256 4c6f55f05715e2b053937c0669989a91cd01dc6d6e01b016e8636ce85dd4936a
MD5 2c8e159df881dff3a031d972a86f783c
BLAKE2b-256 c81d5dac16630c7c2266e68204d2ce24a7fe26095eef00e9488437dafb922afc

See more details on using hashes here.

File details

Details for the file LWWElementGraph-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: LWWElementGraph-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for LWWElementGraph-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2849c995fbe1ab760e629e91eb686a739ee5dea924579d9bd369c1b02019b2cc
MD5 b083c1f509da182ff356b73a998a9172
BLAKE2b-256 b34a5de59f90b4e0ae540b884fec478e0c0540fe2205440945a2010355e8b693

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