Skip to main content

coopgraph

Logical Graph Builder that can be used for various problems that can be modeled as a graph data structure

An Example:

from Graphs import Graph, Node
from dataStructs import Vector2

a = Node(name='A', pos=Vector2(0, 0))
b = Node(name='B', pos=Vector2(3, 3))
c = Node(name='C', pos=Vector2(2, 0))
d = Node(name='D', pos=Vector2(2, 1))
e = Node(name='E', pos=Vector2(3, 4))
f = Node(name='F', pos=Vector2(5, 5))


g = { a: [d],
      b: [c],
      c: [b, d, e],
      d: [a, c],
      e: [c, f],
      f: []
    }

graph = Graph(g)

The graph structure can then be used to perform various graph-related analysis:

Two find nodes that have no outbound connections

print(graph.find_isolated_vertices())

To find the shortest path between two nodes

print(graph.astar(a, e))

Note that for astar calculation, edges can be enabled or disabled against one or more disablers. This is useful for implementing temporary criteria in:

edges_to_disable = [value for key, value in graph.edges()][:3]

graph.disable_edges(edges_to_disable, "myDisabler")
path = graph.astar(a, e)
graph.disable_edges(edges_to_disable, "myDisabler")

you can also ignore disablers directly by passing a list of disabler names to the astar() method

edges_to_disable = [value for key, value in graph.edges()][:3]
graph.disable_edges(edges_to_disable, "myIngoredDisabler")

ignored = ["myIngoredDisabler"]
path = graph.astar(a, e, ignored_disablers=ignored)

An astar() call can also include custom g and h functions that allow for better control of the astar algorithm

def g(node1 Node, node2: Node) -> float:
    if node1.pos - node2.pos > 10:
        return 1
    else
        return .5

def h(node1 Node, node2: Node) -> float:
    if node1.pos - node2.pos > 10:
        return 100
    else
        return -100

path = graph.astar(a, e, g_func=g, h_func=h)

Metadata

Release files for coopgraph 1.13

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

Source distribution (sdist)

Source distribution for coopgraph 1.13
File Size Uploaded Provenance Actions
coopgraph-1.13.tar.gz 17.4 kB Without provenance Details for coopgraph-1.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for coopgraph 1.13
File Interpreter ABI Platform Actions
coopgraph-1.13-py3-none-any.whl Python 3 none any Details for coopgraph-1.13-py3-none-any.whl

Total release size: 33.2 kB

Release files / coopgraph-1.13.tar.gz

Download URL coopgraph-1.13.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
52d5890207b928f1dbc69abc81546defb897bba319b65824d81af0bd272ed392
BLAKE2b-256 checksum
How to use checksums
ba5243d1cb1f8908b83de7e30710129a34c08d8002f24a83be73901a3ea7e055
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release files / coopgraph-1.13-py3-none-any.whl

Download URL coopgraph-1.13-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6709811553a646a549c8d6ff6edb347310222eede952d09fa164c6a348c1982d
BLAKE2b-256 checksum
How to use checksums
0f9f9ff9d64e6e3b7882b7c013a6f92a3347f9129b0113bb81e67edd3e34791e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Security for coopgraph 1.13

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.

Release history Release notifications | RSS feed

This release

1.13 This release

2 release files No provenance

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