Skip to content

Evaluation of a connected directed acyclic graph

Notifications You must be signed in to change notification settings

aliaksandrsauras/dag

Repository files navigation

Evaluation of a connected directed acyclic graph

Build status Python version Code style: black Imports: isort

Getting started

The project contains a python package for evaluating pre-prepared graphs, provided in an xml-based format (GraphML).

Entry point script with example

Pre-prepared graphs

Simple graph description example

<graph>
    <node id="A" operator="sum"/>
    <node id="B" operator="min"/>
    <node id="C" operator="max"/>
    <node id="D"/>
    <node id="E"/>
    <node id="F"/>
    <node id="G"/>
    <edge source="B" target="A"/>
    <edge source="C" target="A"/>
    <edge source="D" target="B"/>
    <edge source="E" target="B"/>
    <edge source="F" target="C"/>
    <edge source="G" target="C"/>
</graph>

Simple usage example

from dag.graph import DAG
from dag.serialization import deserialize

nodes, edges = deserialize("resources/example.xml")
params = {"D": 1, "E": 2, "F": 3, "G": 4}

dag = DAG()
dag.initialize(nodes, edges)

is_valid, _ = dag.validate()

if is_valid:
    print(dag.evaluate(params))

About

Evaluation of a connected directed acyclic graph

Resources

Stars

Watchers

Forks