The Dirac’s theorem states that: “For a Graph G with N vertices, if the degree of each vertex is atleast N/2 then, the Graph has a Hamilton Circuit.” Can the same be said if a graph has a Hamilton Circuit then the degree of each vertex is atleast N/2 ?

# Tag: circuit

## Polynomial size Boolean circuit for counting number of bits

Given a natural number $ n \geq 1$ , I am looking for a Boolean circuit over $ 2n$ variables, $ \varphi(x_1, y_1, \dots, x_n, y_n)$ , such that the output is true if and only if the assignment that makes it true verifies

$ $ \sum_{i = 1}^{i = n} (x_i + y_i) \not\equiv n \bmod 3$ $

I should specify that this I am looking for a Boolean *circuit*, not necessarily a Boolean formula as it is usually written in Conjunctive Normal Form (CNF). This is because when written in CNF, a formula like the one before has a trivial representation where the number of clauses is approximately $ \frac{4^n}{3}$ , as it contains a clause for every assignment $ (x_1, y_1, \dots, x_n, y_n)$ whose bits sum to a value which is congruent with $ n \bmod 3$ . Constructing such a formula would therefore take exponential time.

I have been told that a Boolean circuit can be found for this formula that accepts a representation of size polynomial in $ n$ . However, so far I have been unable to find it. I would use some help; thanks.

## Design a sequential synchronous circuit, what would on two outputs display cyclic values

I’m trying to Design a sequential synchronous circle, what would on two outputs display cyclic values 0/0, 0/1, 1/0, 0/0, 0/1 and so on..

How would I design such circuit? Thanks!

## Boolean circuit size of $i$th bit of determinant?

Berkowitz algorithm provides a polynomial size circuit with logarithmic depth for determinant of a square matrix using matrix powers.

Is there a polynomial size boolean circuit for $ i$ th bit of determinant and is it still logarithmic depth?

## Longest simple circuit and P=NP relation

Given the following function: $ $ \:f\left(G,v\right)\:=\:size\:of\:the\:longest\:simple\:circuit\:in\:a\:directed\:graph\:G\:that\:contains\:v$ $

Output: Function returns a natural number or 0, which is the largest simple circuit in directed graph G.

However, I don’t understand the following claim:

if it is possible to compute in a polynomial time the function g(G,v) and it is guaranteed that: $ f(G,v) -5 ≤ g(G,v) ≤ f(G,v) +5$ , then $ P=NP$ .

I don’t understand why. as far as I know, the longest simple circuit can be proved NP-complete using LongestSimplePath(by adding remaining vertices to a new graph G’ and two directed edges, and then running it) or HamCycle(by constructing an instance of longestsimplecycle(H,|V|) based on hamcycle(H) (can be done in polynomial time) and checking if the longest simple cycle equals to |V|(contains hamiltonian cycle) as the basis for the reductions. So if we know that it is possible to compute in polynomial time g(G,v), I don’t understand how the fact that it is guaranteed that $ f(G,v) -5 ≤ g(G,v) ≤ f(G,v) +5$ helps deduct that P=NP.

There’s probably some trick to it that I cannot see, And would appreciate your help with it. How is it possible to determine that?

## Programs to circuit conversion

Suppose we have an algorithm for a decision problem with $ n$ bit inputs that runs in $ DTIME[f(n)]$ is there ways to convert to circuits of $ O(f(n))$ size with AND, OR and NOT gates?

How about when we go from circuits to programs?

## Circuit breaker open when uploading large file [migrated]

I have an existing project with the following microservice architect. Client –> API Gateway(Spring cloud using Hystrix as circuit breaker) –> UploadService. When uploading small file(`POST /upload/video`

) everything is fine. But when the file is larger then the upload time is very long and Hystrix will be OPEN and return fallback.

Does anyone have practice for my case or how can I set up the timeout for only `POST /upload/video`

request on Hystrix?

## Partitioning a boolean circuit for automatic parallelization

tl;dr: I have a problem where I have a Boolean circuit and need to implement it with very specific single-thread primitives, such that SIMD computation is significantly cheaper after a threshold. I’m trying to optimize the implementation.

Going into detail, the input is a combinatorial Boolean circuit (so no loops, state, etc.). I’m implementing it in software with a rather unusual set of primitives, such that:

- logic gates must be computed one at a time, as the “engine” is single-threaded
- NOT gates are free
- AND, OR, XOR have a cost of 1 (eg. 1 second)
- N identical gates can be evaluated at the same time for a cost of 10 plus some tiny proportional term (eg. a batch of 20 distinct AND gates can be evaluated in 10 seconds, 50 distinct XOR gates in ~10 seconds, etc.)

The objective is to implement the circuit with the given primitives while minimizing the cost.

### What I tried

This problem looks vaguely related to the bin packing problem, but the differences – constraints on the order of the items and different cost for each “bin” depending on the number of items – make me think it’s not particularly applicable.

I was suggested to use integer linear programming, which sounds like the best fit so far, but I’m not sure how to represent the problem. Specifically, I’d use binary variables to represent whether the *implementation* gate/batch M is used in place of the *circuit* gate N, but then I don’t know how to express the objectives to be maximized/minimized.

## How to compose load balancing and circuit breaking for external data source

So I have this issue. My website uses data, that is scraped from a different site – sports results. This data can update in relatively random intervals, but I do not care if my data is a bit stale – it does not have to be instant, but it should update on some regular basis.

At the same time, I cannot just cache the responses from the external site -> I process them and import into a graph database so that I can do other analytics over them.

I would like to have a system like this:

`interface IDataSource { public function getData(): array; } class ExternalDataSource implements IDataSource { // gets data from the external website - the ultimate source of truth } class InternalDataSource implements IDataSource { // gets data from my own graph database } class InternalImportDecorator implements IDataSource { private $ external; public function __contruct(ExternalDataSource $ external) { $ this->external = $ external } public function getData(): array { $ data = $ this-external->getData(); // import the data into my internal DB return $ data; } } class CompositeDataSource implements IDataSource { public function __construct(ExternalDataSource $ external, InternalDataSource $ internal) { $ this->external = new InternalImportDecorator($ external); $ this->internal = $ internal; } public function getData(): array //HERE I NEED HELP { if(rand(0, 100) > 95) {//in 95% of the cases, go for internal DB for data - like weighted load-balancer somewhat //here I need something like "chain of responsibility" in case the internal DB is not yet populated } else { // go for the external data source, so that I can update my internal data //what if the external data source is not available? I need a circuit breaker with fallback to internal //what if I fall back to internal and the internal DB has not yet been populated } } } `

I have a general idea about the code and the composition, I just need help with one method implementation. Or maybe just some nomenclature, how is this situation properly called, so that I can google it myself.

## What is the circuit rank of a complete graph?

The circuit rank of a complete graph with n=4 (6 edges)is 3. The circuit rank of a complete graph with n=5 (10 edges)is 5. I think that the circuit rank of a complete graph with n=6 (15 edges) is 10? I think that the circuit rank of a complete graph with n=7 (21 edges) is 15?

I don’t see the pattern.