-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgraph_inequality.py
More file actions
32 lines (23 loc) · 937 Bytes
/
graph_inequality.py
File metadata and controls
32 lines (23 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from collections import Counter
from gadget import SimGadget, Gadget
class Inequality:
"""Inequality related to the output of a gadget in a gadget graph.
For a t-SNI gadget, the total number of probes (sum over the gadget and all
gadgets connected to the output, taking multiplicity into account) must be
at most t.
"""
def __init__(self, g: SimGadget, outputs: list[Gadget]):
self.g = g
# All gadgets connected to the output of g.
self.outputs = outputs
self.outputs_cnt = Counter(outputs)
self.all_g_cnt = self.outputs_cnt.copy()
self.all_g_cnt.update([g])
def __repr__(self):
return repr(self.g)
def t(self) -> int:
return self.g.t_sni()
def all_g(self) -> list[Gadget]:
return [self.g] + self.outputs
def sim_outputs(self) -> list[SimGadget]:
return [o for o in self.outputs if isinstance(o, SimGadget)]