{"id":48991729,"url":"https://github.com/aabs/petri.net","last_synced_at":"2026-04-18T14:35:37.150Z","repository":{"id":350954412,"uuid":"1205673291","full_name":"aabs/petri.net","owner":"aabs","description":null,"archived":false,"fork":false,"pushed_at":"2026-04-12T23:00:17.000Z","size":283,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-13T01:05:39.324Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-09T07:15:15.000Z","updated_at":"2026-04-12T23:00:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/aabs/petri.net","commit_stats":null,"previous_names":["aabs/petri.net"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/aabs/petri.net","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabs%2Fpetri.net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabs%2Fpetri.net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabs%2Fpetri.net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabs%2Fpetri.net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aabs","download_url":"https://codeload.github.com/aabs/petri.net/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabs%2Fpetri.net/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31972571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-18T14:35:35.138Z","updated_at":"2026-04-18T14:35:37.138Z","avatar_url":"https://github.com/aabs.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# petri.net\n\nThis repository is a progressive modernization of the original [aabs/PetriNets](https://github.com/aabs/PetriNets) project (first created in 2009).\n\nThe goal is to keep the core Petri Net modeling approach intact while updating implementation quality, tests, and runtime behavior for current .NET.\n\n## What You Can Do Here\n\n- Build Place/Transition nets using a fluent builder.\n- Create either graph-backed or matrix-backed net models from the same definition.\n- Run markings through repeated transition firing.\n- Load PNML models into `GraphPetriNet` or `MatrixPetriNet`.\n\n## Project Layout\n\n- `src/core`: Core Petri Net models and builders.\n- `src/cli`: CLI project scaffold.\n- `test/core.tests`: Unit and property tests.\n- `docs`: Notes, plans, and performance work items.\n\n## Build And Test\n\nPrerequisite: .NET SDK 10.0+\n\n```bash\ndotnet build petrinets2.slnx\ndotnet test petrinets2.slnx\n```\n\n## Quick Start: Define A Net Once, Materialize Either Model\n\nBoth `GraphPetriNet` and `MatrixPetriNet` can be created from the same `CreatePetriNet` builder.\n\n```csharp\nusing petrinets2.core;\n\nvar builder = CreatePetriNet\n    .Called(\"demo\")\n    .WithPlaces(\"p0\", \"p1\")\n    .WithTransitions(\"t0\")\n    .With(\"t0\").FedBy(\"p0\").Done()\n    .With(\"t0\").Feeding(\"p1\").Done()\n    .WithPlace(\"p0\").HavingMarking(1).Done();\n\nvar graph = builder.CreateNet\u003cGraphPetriNet\u003e();\nvar matrix = builder.CreateNet\u003cMatrixPetriNet\u003e();\nvar marking = builder.CreateMarking();\n```\n\n## GraphPetriNet Example\n\nUse `GraphPetriNet` when you want direct arc lists and convenient mutation APIs.\n\n```csharp\nusing petrinets2.core;\n\nvar builder = CreatePetriNet\n    .Called(\"graph-example\")\n    .WithPlaces(\"input\", \"output\")\n    .WithTransitions(\"move\")\n    .With(\"move\").FedBy(\"input\").Done()\n    .With(\"move\").Feeding(\"output\").Done()\n    .WithPlace(\"input\").HavingMarking(2).Done();\n\nvar net = builder.CreateNet\u003cGraphPetriNet\u003e();\nvar marking = builder.CreateMarking();\n\nvar moveId = builder.TransitionIndex(\"move\");\nvar inputId = builder.PlaceIndex(\"input\");\nvar outputId = builder.PlaceIndex(\"output\");\n\nwhile (net.IsEnabled(moveId, marking))\n{\n    marking = net.Fire(marking);\n}\n\nConsole.WriteLine($\"input={marking[inputId]}, output={marking[outputId]}\");\n// input=0, output=2\n```\n\n## MatrixPetriNet Example\n\nUse `MatrixPetriNet` when you want matrix-based flow calculations and compact transition evaluation.\n\n```csharp\nusing petrinets2.core;\n\nvar places = new Dictionary\u003cint, string\u003e\n{\n    [0] = \"p0\",\n    [1] = \"p1\"\n};\n\nvar transitions = new Dictionary\u003cint, string\u003e\n{\n    [0] = \"t0\"\n};\n\nvar inArcs = new Dictionary\u003cint, List\u003cInArc\u003e\u003e\n{\n    [0] = new() { new InArc(0, weight: 1, inhibitor: false) }\n};\n\nvar outArcs = new Dictionary\u003cint, List\u003cOutArc\u003e\u003e\n{\n    [0] = new() { new OutArc(1, weight: 1) }\n};\n\nvar net = new MatrixPetriNet(\"matrix-example\", places, transitions, inArcs, outArcs);\n\nvar marking = new Marking(2);\nmarking[0] = 3;\nmarking[1] = 0;\n\nwhile (net.IsEnabled(0, marking))\n{\n    marking = net.Fire(marking);\n}\n\nConsole.WriteLine($\"p0={marking[0]}, p1={marking[1]}\");\n// p0=0, p1=3\n```\n\n## Load PNML Models\n\nThe generic PNML loader can materialize either model type.\n\n```csharp\nusing petrinets2.core;\n\nvar graphLoader = new NewPnmlLoader\u003cGraphPetriNet\u003e();\nvar graphNets = graphLoader.Load(\"model.pnml\").ToList();\n\nvar matrixLoader = new NewPnmlLoader\u003cMatrixPetriNet\u003e();\nvar matrixNets = matrixLoader.Load(\"model.pnml\").ToList();\n```\n\n## Notes On Current Direction\n\n- Runtime target is idiomatic C# 14 on `net10.0`.\n- Correctness is the primary design objective; performance work follows once behavior is preserved and measurable.\n- Tests are property-based and use FsCheck with FsCheck.Xunit under red-green-refactor discipline.\n- Method contracts should be expressed with idiomatic C# constructs rather than the deprecated Code Contracts library.\n- The repository includes performance remediation notes in `docs/performance-remediation-plan.md`.\n\nIf you are migrating from the 2009 codebase, start by defining one net with `CreatePetriNet`, then instantiate both models and compare behavior under the same marking progression.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faabs%2Fpetri.net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faabs%2Fpetri.net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faabs%2Fpetri.net/lists"}