2023-05-04 18:10:31 +02:00
<!--
SPDX-FileCopyrightText: 2023 Ämin Baumeler < amin @ indyfac . ch > and Eleftherios-Ermis Tselentis < eleftheriosermis.tselentis @ oeaw . ac . at >
2023-05-03 19:10:35 +02:00
2023-05-04 18:10:31 +02:00
SPDX-License-Identifier: GPL-3.0-or-later
-->
2023-05-03 19:10:35 +02:00
2023-05-04 18:10:31 +02:00
# SOC Observation Code
2023-05-03 19:10:35 +02:00
2023-05-04 18:10:31 +02:00
## Description
2023-09-07 10:03:10 +02:00
SOC stands for **S**OC **O**bservation **C**ode, and is composed of three C programs and a python script:
2023-05-03 19:10:35 +02:00
2023-05-04 18:10:31 +02:00
- One, `SOCgen` , to generate SOC graphs (here, SOC stands for Siblings-on-Cycles),
2023-05-11 14:34:12 +02:00
- and another, `SOCadmissible` , to verify the admissibility of these graphs as quantum causal structures,
2023-09-07 10:03:10 +02:00
- and the last, `SOCgraphviz` , to translate adjacency matrices into the [Graphviz language ](https://graphviz.org/ ).
- The python script `/tools/removeiso.py` removes isomorphic graphs.
2023-05-03 19:10:35 +02:00
2023-10-12 08:13:29 +02:00
The first two programs are used in support of Conjecture 1 in the article [Admissible Causal Structures and Correlations, PRX Quantum 4, 040307 (2023) ](https://doi.org/10.1103/PRXQuantum.4.040307 ) ([arXiv:2210.12796 \[quant-ph\]](https://arxiv.org/abs/2210.12796)).
2023-05-03 19:10:35 +02:00
2023-05-04 18:10:31 +02:00
## Installation
First, clone this repository, and then simply run
2023-05-03 19:10:35 +02:00
```
2023-05-04 18:10:31 +02:00
$ cd soc-observation-code/
$ make
2023-05-03 19:10:35 +02:00
```
2023-05-11 14:34:12 +02:00
This compiles the programs `SOCgen` , `SOCadmissible` , and `SOCgraphviz` .
2023-05-03 19:10:35 +02:00
## Usage
2023-05-04 18:10:31 +02:00
To display help and exit, run the respective program without command-line arguments.
2023-05-03 19:10:35 +02:00
2023-05-04 18:10:31 +02:00
### SOCgen
```
$ ./SOCgen
2023-09-14 14:24:31 +02:00
Usage: ./SOCgen -n < order > [-r < num > ] [--graphviz] [FILTER ...]
2023-05-04 18:10:31 +02:00
-n < order > Generate SOCs with `order' connected nodes
-r < num > Pick directed graphs at random, and exit after having found `num' SOCs
2023-09-07 10:03:10 +02:00
--graphviz Output SOCs in Graphviz format, arcs of common parents are highlighted
2024-11-15 16:02:06 +01:00
--vector Output SOCs adjacency vectors in the order (0< -1 , 0 < -2 , . . . , 1 < -0 , 1 < -2 , . . . )
--all Allow for disconnected SOCs and disable the degree-order filter (see below)
2023-05-04 18:10:31 +02:00
[FILTER] Consider only simple directed graphs ...
-c ... that are cyclic (i.e., not DAGs)
--no-sink ... without sink nodes (this logically implies -c)
--no-source ... without source nodes (also this logically implies -c)
2023-09-14 14:24:31 +02:00
This program prints the found SOCs as adjacency matrices to stdout, unless --graphviz has been specified.
2024-11-15 16:02:06 +01:00
To exclude (some) of the isomorphic SOCs, it uses a degree-order filter, unless --all is specified.
2023-05-04 18:10:31 +02:00
```
2023-05-03 19:10:35 +02:00
2023-05-04 18:10:31 +02:00
### SOCadmissible
```
$ ./SOCadmissible
Usage: ./SOCadmissible < filename > [< startline > [< endline > | +< count > ]]
< filename > File name with adjacency matrices of simple directed graphs
< startline > Verify graphs starting from line `startline'
< endline > Verify graphs up to and including line `endline'
+< count > Verify `count' number of graphs
[FILE FORMAT]
Each line in `filename' must contain the adjacency matrix of a simple directed graph in the format
{{a00,a01,...},{a10,a11,...},...} where aij=1 if and only if the graph has the edge i -> j
The file `filename' may contain graphs with different order (number of vertices)
This program verifies the admissibility of simple directed graphs.
```
2023-05-03 19:10:35 +02:00
2023-05-11 14:34:12 +02:00
### SOCgraphviz
```
$ ./SOCgraphviz
2023-09-14 14:24:31 +02:00
Usage: ./SOCgraphviz < filename > [night]
2023-05-11 14:34:12 +02:00
< filename > File name with adjacency matrices of simple directed graphs
[FILE FORMAT]
Each line in `filename' must contain the adjacency matrix of a simple directed graph in the format
{{a00,a01,...},{a10,a11,...},...} where aij=1 if and only if the graph has the edge i -> j
The file `filename' may contain graphs with different order (number of vertices)
This program translates to adjacency matrices into the Graphviz format, and prints them to stdout.
2023-09-14 14:24:31 +02:00
Try the optional argument ``night'' for star-constallation-like output.
2023-05-11 14:34:12 +02:00
```
2023-09-07 10:03:10 +02:00
### removeiso.py
```
$ ./tools/removeiso.py
Usage: ./tools/removeiso.py -f < filename >
Filters out the isomorphic graphs in `filename'.
```
This script requires [NumPy ](https://numpy.org/ ) and [NetworkX ](https://networkx.org/ ).
2023-05-11 14:34:12 +02:00
### Examples
2023-09-07 10:03:10 +02:00
To generate all SOCs with three nodes, and save them in the file `3.soc` , you may run:
2023-05-04 18:10:31 +02:00
```
$ ./SOCgen -n 3 > 3.soc
Generating SOCs with 3 nodes
2023-05-08 20:53:16 +02:00
100.00% 64/64 (6 SOCs found, 0 seconds, 64.00 graphs/s, 6.00 SOCs/s, 0.00h estimated time left)
Found 6 SOCs in 0 seconds
2023-05-04 18:10:31 +02:00
```
The admissibility of these graphs can then be checked by running:
```
$ ./SOCadmissible 3.soc
Verifying the admissibility of 6 graphs in the file `3.soc' (line 1 to line 6)
2023-05-08 20:53:16 +02:00
100.00% 6/6 (6.00 graphs/s in 0 seconds; current line 6)
2023-05-04 18:10:31 +02:00
These graphs are admissible
```
2023-05-03 19:10:35 +02:00
2023-05-11 14:34:12 +02:00
The SOCs generated can easily be displayed with the [Graphviz ](https://graphviz.org/ ) tools:
```
2023-09-07 10:03:10 +02:00
$ ./SOCgraphviz 3.soc | dot | gvpack | circo -Nshape=point -Tx11
```
also with the `--graphviz` option:
```
$ ./SOCgen -n 3 --graphviz | dot | gvpack | neato -Tx11
2023-05-11 14:34:12 +02:00
```
or in [Wolfram Mathematica ](https://www.wolfram.com/mathematica/ ) using:
2023-05-04 18:46:15 +02:00
```
2023-05-11 14:34:12 +02:00
SOCs = AdjacencyGraph[#] & /@ ToExpression[Import["./3.soc", "List"]];
2023-05-04 18:46:15 +02:00
SOCs = DeleteDuplicatesBy[SOCs, CanonicalGraph];
SOCs
```
2023-09-07 10:03:10 +02:00
To generate all SOCs with four nodes, save them in the file `4.soc` , remove isomorphic ones (as stated below, `SOCgen` only rudimentary checks for isomorphic graphs), and to display them using Graphviz, you may run:
2023-05-11 14:34:12 +02:00
```
2023-09-07 10:03:10 +02:00
$ ./SOCgen -n 4 | tee 4.soc | ./tools/removeiso.py -f 4.soc | ./SOCgraphviz /dev/stdin | dot | gvpack | circo -Nshape=point -Tx11
2023-05-11 14:34:12 +02:00
```
2023-09-07 10:03:10 +02:00
2023-05-11 14:34:12 +02:00
![All SOCs with four nodes ](./example.png "SOCs with four nodes" )
2023-05-04 18:10:31 +02:00
## Limitations
In `SOCgen` , each simple directed graph is represented by a 64bit unsigned integer:
This integer is interpreted as a vector of bits, where each bit specifies the absence or presence of a directed edge from one node to another.
Since we consider simple directed graphs only (no self-loops), there are `n(n-1)` possible directed edges, where `n` is the number of nodes.
This means that the largest number of nodes possible is limited by `n=8` .
2023-05-03 19:10:35 +02:00
2023-05-11 13:54:55 +02:00
While the SOCs generated by `SOCgen` satisfy some degree-order (see function `isdegreeordered(...)` in [SOCgen.c ](./src/SOCgen.c )), `SOCgen` does not perform graph-isomorphism tests, and may output multiple isomorphic graphs.
2023-05-04 18:46:15 +02:00
2023-05-03 19:10:35 +02:00
## License
2023-05-11 13:54:55 +02:00
[GPL-3.0-or-later ](./LICENSES/GPL-3.0-or-later.txt )