Skip to main content

Dynamic BFS algorithm to compress graph for reachability queries

Project description

DABFS

DABFS (Dynamic Approach with BFS) is a Python package for query-preserving graph compression. It efficiently compresses directed graphs while preserving reachability queries, enabling scalable query processing on large graphs.


Installation

pip install dabfs

Or, install locally from the repository:

git clone https://github.com/resultugay/dabfs.git

Usage

from dabfs import dabfs_compress
# Call DABFS with your edge list file
dabfs_compress("dabfs/data/simple_graph.txt")

Example Input

A text file containing the edge list of the graph. Each row represents an edge with two columns: source_node and target_node. Example of simple_graph.txt:

1 2
2 3
3 4
4 1
5 6

Example Output

After running dabfs_compress("dabfs/data/wiki.txt"):
2026-04-07 13:49:02,384 - INFO - Total dynamic BFS time for finding all ancestors 7.14 sec
2026-04-07 13:49:13,670 - INFO - Candidate Generated 3.22 sec
2026-04-07 13:49:30,034 - INFO - Saved compressed data dabfs/output/reachibility_query_compressed.txt
2026-04-07 13:49:30,037 - INFO - number of nodes: 7115
2026-04-07 13:49:30,037 - INFO - number of edges: 103689
2026-04-07 13:49:30,037 - INFO - Compressed number of nodes: 3289
2026-04-07 13:49:30,037 - INFO - Compressed number of edges: 77846
2026-04-07 13:49:30,037 - INFO - Compression ratio: 0.73 (73.22%)
2026-04-07 13:49:30,037 - INFO - Compression factor: 0.27 (26.78%)

Basic Example

from dabfs import dabfs_compress
# Compress the graph and save outputs
dabfs_compress("dabfs/data/simple_graph.txt")

Using Compressed Graphs

from graph import Graph
from data_reader import read_data
g = Graph()
compressed_graph = read_data("dabfs/output/reachability_query_compressed.txt",g)

You can now run reachability queries directly on reachability_query_compressed.

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

dabfs-1.0.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

dabfs-1.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file dabfs-1.0.0.tar.gz.

File metadata

  • Download URL: dabfs-1.0.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for dabfs-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a61d6eeb732599f1a1ec8bb337b8888476b41d937627ffea1f7a1a61868f26ed
MD5 4c2234c2df116865b0b04f8929b65cc2
BLAKE2b-256 12848ed12559d78c90c9959130aba0d94c1f37a585fce0f718791f0622b406ab

See more details on using hashes here.

File details

Details for the file dabfs-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dabfs-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for dabfs-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95db47bb56f066e920725a2c7a4155528e1f1dac1d8c4fb52394e4bd42dc179b
MD5 d2376abe6f688ca0979de947dd5c4218
BLAKE2b-256 5976f49e096c4f17d3f8f7e24e0812a821106823319036433d2d3bba6812170f

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