nan-graph (Python)
Port en Python del core
@carloscortezcloud/nan-graph(TypeScript) — el motor del grafo de SOFE Architecture Graph (fusión Ñan × BYaML v2). OSS, Apache-2.0, bajobreakingthecloud.Misma API que el core TS; se mantiene en sync manual (patrón
styrr→styrr-py).
Grafo dirigido en memoria con relaciones tipadas: traversal BFS/DFS, blast radius, cost chain, fan-in / SPOF, y filtrado por tipo de relación.
Install
pip install nan-graph
Uso
from nangraph import NanGraph, blast_radius, cost_chain, from_yaml
g = (
NanGraph()
.add_node({"id": "api", "type": "aws.apigateway", "attrs": {"monthly_cost": 20}})
.add_node({"id": "lambda", "type": "aws.lambda", "attrs": {"monthly_cost": 5}})
.add_node({"id": "ddb", "type": "aws.dynamodb", "attrs": {"monthly_cost": 30}})
.add_edge("api", "lambda", "routes_to")
.add_edge("lambda", "ddb", "reads_writes")
)
blast_radius(g, "api") # ['lambda', 'ddb'] — qué se cae si api falla
cost_chain(g, "api") # 55.0 — costo downstream total
Importar desde YAML / JSON
from nangraph import from_yaml, from_object
# estilo dependency-graph.yaml
g = from_yaml("""
nodes:
sofe-engine: { type: python-library }
sofe-server: { type: python-api }
edges:
- { from: sofe-engine, to: sofe-server, relType: bundles }
""")
# estilo BYaML v0.3 (components + relationships)
g2 = from_object({
"components": [{"id": "api", "type": "aws.apigateway", "monthly_cost": 20}],
"relationships": [{"from": "api", "to": "lambda", "type": "routes_to"}],
})
API
| Función | Descripción |
|---|---|
NanGraph() |
Grafo dirigido multi-borde en memoria |
add_node(dict) / add_edge(from, to, rel_type) |
Añadir nodo/arista (auto-crea nodos) |
get_related(id, rel_type?, direction?) |
Vecinos outgoing/incoming/both, con filtro |
traverse_bfs(g, start, rel_types?, max_depth?, direction?) |
BFS |
traverse_dfs(g, start, ...) |
DFS |
blast_radius(g, start) |
Nodos afectados downstream si start falla |
cost_chain(g, start) |
Suma attrs.monthly_cost de start + downstream |
team_cost(g, owner) |
Suma de costo por attrs.owner |
fan_in(g, id) / single_points_of_failure(g, threshold) |
SPOF por alta dependencia entrante |
from_object(dict) / from_yaml(str) / from_json(str) |
Construir grafo desde input |
Paridad con el core TS
TS (@carloscortezcloud/nan-graph) |
Python (nan-graph) |
|---|---|
new NanGraph() |
NanGraph() |
g.addNode / g.addEdge |
g.add_node / g.add_edge |
g.getRelated |
g.get_related |
traverseBFS / traverseDFS |
traverse_bfs / traverse_dfs |
blastRadius / costChain |
blast_radius / cost_chain |
teamCost / fanIn / singlePointsOfFailure |
team_cost / fan_in / single_points_of_failure |
fromObject / fromYaml / fromJson |
from_object / from_yaml / from_json |
Licencia
Apache-2.0. Ver LICENSE.
Metadata
Release files for nan-graph 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nan_graph-0.1.0.tar.gz | 17.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nan_graph-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.6 kB
Release files / nan_graph-0.1.0.tar.gz
| Download URL | nan_graph-0.1.0.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
501104a9815b18a3c286cfc26022c26b2e1889a92b8bda6bd543a9417581ec9d
|
|
BLAKE2b-256 checksum How to use checksums |
f0700c60ed94730b818ed658807c59b80464bc15972eb83d8cd8885027d4066d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Release files / nan_graph-0.1.0-py3-none-any.whl
| Download URL | nan_graph-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e84fbb391d8f22a0d22ecc2d9642453cfc1a0525a3fc54a6703369035dcb53dc
|
|
BLAKE2b-256 checksum How to use checksums |
a6ecae3cef7010cc19150b7fc8e5908e7688572f479fa6d47116159cf854770a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Security for nan-graph 0.1.0
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.