Skip to content

Commit b778f46

Browse files
committed
reorganize repo
1 parent 3615bb5 commit b778f46

File tree

150 files changed

+86
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+86
-13
lines changed

README.md

+23-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
1-
# The Clique-Picking Algorithm
1+
# Clique-Picking
22

3-
This repository countains multiple implementations of the Clique-Picking algorithm that we have proposed at AAAI 2021 [1] for counting the number of Markov equivalent DAGs in polynomial time.
4-
Moreover, we give implementations of the polynomial-time algorithm for uniformly sampling a DAG from a Markov Equivalence Class, which we refined in [2]. See also chapter 5 of my thesis [3].
3+
This repository provides functionality for working with CPDAGs, which are graphs representing Markov equivalence classes (MEC) of DAGs common in causal discovery. Currently, it focuses mostly on algorithms for counting, sampling and listing the DAGs in the MEC represented by a given CPDAG based on my [PhD thesis](https://mwien.github.io/thesis.pdf).
54

6-
1. Marcel Wienöbst, Max Bannach, and Maciej Liśkiewicz: *Polynomial-Time Algorithms for Counting and Sampling Markov Equivalent DAGs* (AAAI 2021) [arXiv version](https://arxiv.org/abs/2012.09679)
7-
2. Marcel Wienöbst, Max Bannach, and Maciej Liśkiewicz: *Polynomial-Time Algorithms for Counting and Sampling Markov Equivalent DAGs with Applications* [(JMLR)](https://www.jmlr.org/papers/v24/22-0495.html)
8-
3. Marcel Wienöbst: *Algorithms for Markov Equivalence* [(PhD Thesis)](https://mwien.github.io/thesis.pdf)
5+
The algorithms are implemented in Rust and exposed via an Python wrapper available as Pypi package ```cliquepicking```. An R wrapper is planned.
6+
7+
## Installation
8+
9+
The python package can be installed with
10+
```
11+
pip install cliquepicking
12+
```
913

10-
## Implementations
14+
For more detailed documentation, see the README in the ```cliquepicking_python``` folder.
1115

12-
We provide the following implementations:
16+
## Roadmap
1317

14-
- ```aaai_experiments/``` contains the original C++ implementation and experiments from the AAAI 2021 conference paper (only counting is implemented here)
15-
- ```cliquepicking_julia/``` contains the subsequent Julia code additionally provides a sampling algorithm
16-
- ```cliquepicking_rs/``` contains a recent Rust implementation for counting and sampling, which is cleaner and slightly more efficient (worst-case n^3)
17-
- ```cliquepicking_python/``` contains a Python wrapper for the Rust implementation. You can install and use the Python implementation easily via ```pip install cliquepicking```.
18+
The goal is to implement further algorithms from [3], such as those for MPDAGs. Feature requests are welcome.
19+
20+
## References
21+
The repository contains an implementation of the Clique-Picking algorithm proposed at AAAI 2021 [1] for counting the number of Markov equivalent DAGs in polynomial time.
22+
Moreover, it provides implementations of the polynomial-time algorithm for uniformly sampling a DAG from a Markov Equivalence Class, which were refined in [2]. See also Chapter 5 of [3].
23+
24+
1. Marcel Wienöbst, Max Bannach, and Maciej Liśkiewicz: *Polynomial-Time Algorithms for Counting and Sampling Markov Equivalent DAGs* (AAAI 2021) [arXiv version](https://arxiv.org/abs/2012.09679)
25+
2. Marcel Wienöbst, Max Bannach, and Maciej Liśkiewicz: *Polynomial-Time Algorithms for Counting and Sampling Markov Equivalent DAGs with Applications* [(JMLR)](https://www.jmlr.org/papers/v24/22-0495.html)
26+
3. Marcel Wienöbst: *Algorithms for Markov Equivalence* [(PhD Thesis)](https://mwien.github.io/thesis.pdf)
1827

19-
Brief examples of how to install and use the implementations are given in the subdirectories.
28+
## Prototypes
29+
The prototypes directory contains code I wrote in the context of the papers [1] and [2], which is not maintained anymore.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import cliquepicking as cp
2+
3+
# DISCLAIMER: I currently use this for some basic profiling
4+
# file reading is hacky
5+
6+
filename = "../prototypes/aaai_experiments/instances/peo-4/peo-n=4096-4-nr=1.gr"
7+
with open(filename, "r") as file:
8+
next(file)
9+
next(file)
10+
input = [tuple(map(int, line.split())) for line in file]
11+
cpdag = []
12+
for pair in input:
13+
cpdag.append((pair[0], pair[1]))
14+
cpdag.append((pair[1], pair[0]))
15+
print(cp.mec_size(cpdag))
16+
sampler = cp.MecSampler(cpdag)
17+
print(len(sampler.sample_dag()))
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import cliquepicking as cp
2+
import networkx as nx
3+
4+
G = nx.DiGraph()
5+
G.add_edge(0, 1)
6+
G.add_edge(1, 0)
7+
G.add_edge(0, 2)
8+
G.add_edge(2, 0)
9+
G.add_edge(1, 2)
10+
G.add_edge(2, 1)
11+
G.add_edge(1, 3)
12+
G.add_edge(3, 1)
13+
G.add_edge(1, 4)
14+
G.add_edge(4, 1)
15+
G.add_edge(1, 5)
16+
G.add_edge(5, 1)
17+
G.add_edge(2, 3)
18+
G.add_edge(3, 2)
19+
G.add_edge(2, 4)
20+
G.add_edge(4, 2)
21+
G.add_edge(2, 5)
22+
G.add_edge(5, 2)
23+
G.add_edge(3, 4)
24+
G.add_edge(4, 3)
25+
G.add_edge(4, 5)
26+
G.add_edge(5, 4)
27+
print(cp.mec_size(list(G.edges)))
28+
29+
sampler = cp.MecSampler(list(G.edges))
30+
for _ in range(5):
31+
print(nx.DiGraph(sampler.sample_dag()))
32+
33+
for _ in range(5):
34+
print(sampler.sample_order())

prototypes/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Prototypes
2+
3+
This directory contains prototypes, which I implemented for [1] and [2]. More precisely:
4+
5+
6+
- ```aaai_experiments/``` contains the original C++ implementation and experiments from the AAAI 2021 conference paper (only counting is implemented here)
7+
- ```cliquepicking_julia/``` contains the subsequent Julia code additionally provides a sampling algorithm
8+
9+
This code is not maintained anymore and is also slower than the Python wrapped Rust code in this repository.
10+
11+
1. Marcel Wienöbst, Max Bannach, and Maciej Liśkiewicz: *Polynomial-Time Algorithms for Counting and Sampling Markov Equivalent DAGs* (AAAI 2021) [arXiv version](https://arxiv.org/abs/2012.09679)
12+
2. Marcel Wienöbst, Max Bannach, and Maciej Liśkiewicz: *Polynomial-Time Algorithms for Counting and Sampling Markov Equivalent DAGs with Applications* [(JMLR)](https://www.jmlr.org/papers/v24/22-0495.html)

0 commit comments

Comments
 (0)