Skip to main content

base-dag

A simple base implementation of a DAG. Users should feel free to subclass this DAG class to provide their desired functionality. The API is intended to be similar to the NetworkX API, though not an exact replica. Note that multiple edges between the same two nodes are not supported by this package.

Creating a DAG.

from base_dag import DAG

# Initialize the DAG
dag = DAG()

# Add nodes and edges
dag.add_nodes_from([1, 2])
dag.add_node(3)
dag.add_edge((1, 2))
dag.add_edge((2, 3))

# Remove nodes and edges
dag.remove_edge((2, 3))
dag.remove_node(3)

Subgraph

# Re-add a third node.
dag.add_node(3)
# Extract the subgraph of nodes 1 and 2.
sub_dag = dag.subgraph([1, 2])

Other Operations

All nodes & edges

all_nodes = dag.nodes() # (1, 2, 3)
all_edges = dag.edges() # ( (1, 2), (2, 3) )

Successors and Predecessors

successors = dag.successors(1) # [2]
predecessors = dag.predecessors(2) # [1]

Descendants and Ancestors

descendants = dag.descendants(1) # [2, 3]
ancestors = dag.ancestors(2) # [1]

Indegree and Outdegree

in_degree = dag.indegree(2) # 1
out_degree = dag.outdegree(1) # 1

Reverse

# Reverse the direction of the edges in the graph in place, without affecting the nodes at all.
dag.reverse()

Topological sort

sorted_nodes = dag.topological_sort()

Topological generations

generations = dag.topological_generations()

Sorted topological generations

sorted_generations = dag.sorted_topological_generations()

has_path

has_path = dag.has_path(1, 3) # True

is_acyclic

is_acyclic = dag.is_acyclic() # True

Metadata

Release files for base-dag 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for base-dag 0.1.10
File Size Uploaded Provenance Actions
base_dag-0.1.10.tar.gz 6.4 kB Without provenance Details for base_dag-0.1.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for base-dag 0.1.10
File Interpreter ABI Platform Actions
base_dag-0.1.10-py2.py3-none-any.whl Python 3, Python 2 none any Details for base_dag-0.1.10-py2.py3-none-any.whl

Total release size: 12.4 kB

Release files / base_dag-0.1.10.tar.gz

Download URL base_dag-0.1.10.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5f3115e5c9580b5ac7cfa9937a1f5db69eb2d6b4418faacd25b28d62a69ff99a
BLAKE2b-256 checksum
How to use checksums
4d31768a099b16df5f7697a20c7b7214ae31dd7452a3460982c349b5d49b42b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / base_dag-0.1.10-py2.py3-none-any.whl

Download URL base_dag-0.1.10-py2.py3-none-any.whl
Size 6.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
9ed2b2016893ab108fc4e65775c0cae7066d4f653aa58c4f5e8ca3df916f48e3
BLAKE2b-256 checksum
How to use checksums
0898ac59a07cf63a465980ebfb845fd0ff3c0626571bd5b289f5f7a6a0e54f15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Security for base-dag 0.1.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page