Skip to main content

Finding common subpaths between paths.

Project description

Subpaths

Finding common subpaths and counting occurrences of all subpaths between paths.

Examples

Finding common subpaths between paths

from pprint import pprint
from subpaths.subpaths import find_all_common_subpaths_between

path_a = [1, 2, 3, 4, 5]
path_b = [3, 4, 5, 7]
path_c = [2, 3, 4, 8, 9, 7]

pprint(find_all_common_subpaths_between(path_a, path_b, path_c))

Will return:

{(3, 4)}

Counting all subpaths between paths

from pprint import pprint
from subpaths.subpaths import find_all_subpath_occurrences

path_a = [1, 2, 3, 4, 5]

pprint(find_all_subpath_occurrences(path_a))

path_b = [3, 4, 5, 7]
path_c = [2, 3, 4, 8, 9, 7]

pprint(find_all_subpath_occurrences(path_a, path_b, path_c))

Will return:

defaultdict(<class 'int'>,
            {(1, 2): 1,
             (1, 2, 3): 1,
             (1, 2, 3, 4): 1,
             (1, 2, 3, 4, 5): 1,
             (2, 3): 1,
             (2, 3, 4): 1,
             (2, 3, 4, 5): 1,
             (3, 4): 1,
             (3, 4, 5): 1,
             (4, 5): 1})
defaultdict(<class 'int'>,
            {(1, 2): 1,
             (1, 2, 3): 1,
             (1, 2, 3, 4): 1,
             (1, 2, 3, 4, 5): 1,
             (2, 3): 2,
             (2, 3, 4): 2,
             (2, 3, 4, 5): 1,
             (2, 3, 4, 8): 1,
             (2, 3, 4, 8, 9): 1,
             (2, 3, 4, 8, 9, 7): 1,
             (3, 4): 3,
             (3, 4, 5): 2,
             (3, 4, 5, 7): 1,
             (3, 4, 8): 1,
             (3, 4, 8, 9): 1,
             (3, 4, 8, 9, 7): 1,
             (4, 5): 2,
             (4, 5, 7): 1,
             (4, 8): 1,
             (4, 8, 9): 1,
             (4, 8, 9, 7): 1,
             (5, 7): 1,
             (8, 9): 1,
             (8, 9, 7): 1,
             (9, 7): 1})

Download

pip install subpaths

Future Improvements

  • Bound the shorted and longest paths to generate and count

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

subpaths-0.2.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

subpaths-0.2.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file subpaths-0.2.0.tar.gz.

File metadata

  • Download URL: subpaths-0.2.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for subpaths-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4e3b9deaa5c519844d253d3f1d29568b79cc9c649378b336c560cb70182ace0f
MD5 b1f1716520be895575b0284d6a8307d4
BLAKE2b-256 d2ea2ac1931758c8fc53c231466c1b5efe8424c1cbc26ca6ebedcd0bcbd7ca94

See more details on using hashes here.

File details

Details for the file subpaths-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: subpaths-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for subpaths-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de76e58820992ce18fd4e11eb7ca349385bf3f58c7c6bc19a28876a4494ffefd
MD5 d8e7c0d71f7a98f1a53f26186e37d5c7
BLAKE2b-256 31a98e22833920850b94e7efc55b2a25214b5473da5ed19fee7092d68d8a046d

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