Skip to content

ritamzico/pgraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pgraph

A probabilistic graph inference engine written in Go. Models directed graphs where edges are independent Bernoulli random variables with associated probabilities. Designed for risk analysis, network reliability, and probabilistic reachability queries.

Note: pgraph is experimental and not intended for production use. APIs, DSL syntax, and serialization formats may change without notice.

Features

  • Probabilistic directed graph model with edge probabilities
  • Path inference — most probable path or top-K paths
  • Exact and Monte Carlo reachability analysis
  • Composite queries — AND, OR, conditional, threshold, aggregate
  • Query DSL for graph construction and inference
  • Go library and interactive CLI interfaces
  • Batch scripting — run .pgraph script files for reproducible analysis

Installation

go install github.com/ritamzico/pgraph/cmd/cli@latest        # CLI

Or build from source:

git clone https://github.com/ritamzico/pgraph.git
cd pgraph
make build        # produces ./bin/pgraph-cli

Quick Start

pg := pgraph.New()
pg.Query("CREATE NODE supplier, factory, warehouse, retailer")
pg.Query("CREATE EDGE e1 FROM supplier TO factory PROB 0.95")
pg.Query("CREATE EDGE e2 FROM factory TO warehouse PROB 0.9")
pg.Query("CREATE EDGE e3 FROM warehouse TO retailer PROB 0.85")

result, _ := pg.Query("REACHABILITY FROM supplier TO retailer EXACT")
fmt.Println(result)

Batch Scripting

Write a .pgraph script file and run it for reproducible analysis:

# analysis.pgraph
new supply_chain
CREATE NODE supplier, factory, retailer
CREATE EDGE e1 FROM supplier TO factory PROB 0.95
CREATE EDGE e2 FROM factory TO retailer PROB 0.9
REACHABILITY FROM supplier TO retailer EXACT
CONDITIONAL GIVEN EDGE e1 INACTIVE ( REACHABILITY FROM supplier TO retailer EXACT )
./bin/pgraph-cli run analysis.pgraph           # human-readable output
./bin/pgraph-cli run analysis.pgraph --json    # newline-delimited JSON
./bin/pgraph-cli run analysis.pgraph --continue  # don't stop on first error

Documentation

License

MIT

About

A probabilistic graph inference engine written in Go. Models directed graphs where edges are independent Bernoulli random variables with associated probabilities. Designed for risk analysis, network reliability, and other probabilistic reachability queries.

Topics

Resources

License

Stars

Watchers

Forks

Contributors